<?php
/**
 *
 * @package 
 * @since 1.0
 * @todo 首页、列表页面、详细页
 */
 
class IndexAction extends AllAction{

	/**
	 +----------------------------------------------------------
	 * 预处理
	 * --------------------------------
	 +----------------------------------------------------------
	 */
	 
	 //小喇叭刷新
	function doxiaolabashuaxin(){
		 //小喇叭
		 $xiaolabazuixin = M('xiaolaba')->order('time desc')->limit(1)->find();
		 
		 	$xiaolabazuixinzuozhe = M('user')->find($xiaolabazuixin['zuozhe']);
			$xiaolabazuixin['zuozhename']=$xiaolabazuixinzuozhe['nicheng'];
		 
		$ccc="<marquee onmouseover=this.stop() onmouseout=this.start() direction=left style=\"float:left;width:740px;height:30px;\" scrolldelay=150  behavior=scroll>".$xiaolabazuixin['zuozhename']." : ".$xiaolabazuixin['content']."</marquee>";	
		echo  json_encode($ccc);

	}
	 
	/**
	 +----------------------------------------------------------
	 * 首页
	 +----------------------------------------------------------
	 */
	 function index(){
		 //小喇叭
		 $xiaolabazuixin = M('xiaolaba')->order('time desc')->limit('0,1')->select();
		 foreach($xiaolabazuixin as $k=>$v){
		 	$xiaolabazuixinzuozhe = M('user')->find($v['zuozhe']);
			$xiaolabazuixin[$k]['zuozhename']=$xiaolabazuixinzuozhe['nicheng'];
		 }
		 $this->assign('xiaolabazuixin',$xiaolabazuixin);
		 
		 //文字链
		 $wenzilian1 = M('weibo')->where("wenzilian=1")->order('wtime desc')->limit('0,1')->select();
		 $this->assign('wenzilian1',$wenzilian1);
		 $wenzilian2 = M('weibo')->where("wenzilian=1")->order('wtime desc')->limit('1,4')->select();
		 $this->assign('wenzilian2',$wenzilian2);
		 $wenzilian3 = M('weibo')->where("wenzilian=1")->order('wtime desc')->limit('5,4')->select();
		 $this->assign('wenzilian3',$wenzilian3);
		 $wenzilian4 = M('weibo')->where("wenzilian=1")->order('wtime desc')->limit('9,1')->select();
		 $this->assign('wenzilian4',$wenzilian4);
		 $wenzilian5 = M('weibo')->where("wenzilian=1")->order('wtime desc')->limit('10,4')->select();
		 $this->assign('wenzilian5',$wenzilian5);
		 $wenzilian6 = M('weibo')->where("wenzilian=1")->order('wtime desc')->limit('14,4')->select();
		 $this->assign('wenzilian6',$wenzilian6);
		//频道列表
		$pindao = M('pindao')->order('id asc')->select();
		$this->assign('pindao',$pindao);
		//精品推荐列表
		
		$pindaoid=$_GET["pindaoid"];
		$nowtime=time();
		if($pindaoid==""){
		 import("@.ORG.Page");
		 	$count	= M('weibo')->where("zhuanfazhe=0 and tuijian=1 and $nowtime-time<60*60*24")->count();
			$Page	= New Page($count,6);
			$show	= $Page->show();
			
			
			$jingpin = M('weibo')->where("zhuanfazhe=0 and tuijian=1 and $nowtime-time<60*60*24")->order('ttime desc,jtime desc')->limit($Page->firstRow.','.$Page->listRows)->select();
	         foreach($jingpin as $k=>$v){
				foreach($jingpin[$k] as $ks=>$vs){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$jingpin[$k][$ks]=stripslashes($vs); 
					} 
				}
					$jingpin[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
						foreach($jingpin[$k]['pinglun'] as $kk=>$vv){
							$fasongzhe=M('user')->find($vv['fasongzhe']);
							$jingpin[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
							$jingpin[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
							$jingpin[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
							foreach($jingpin[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
								$nicheng=M('user')->find($vvv['fasongzhe']);
								$jingpin[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
								$jingpin[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
							}
						}
				 
				 $zuozhe=M('user')->find($v['zuozhe']);
				 $jingpin[$k]['user_name']=$zuozhe['nicheng'];
				 $jingpin[$k]['user_touxiang']=$zuozhe['touxiang'];
				 $jingpin[$k]['user_id']=$zuozhe['id'];
				 //时间格式转换开始			 
				 if(date("YmdHi",$jingpin[$k]['time'])==date("YmdHi",time())){
				 	 $jingpin[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$jingpin[$k]['time'])."秒前";	 
				 }else{
					 if(date("YmdH",$jingpin[$k]['time'])==date("YmdH",time())){
						 $jingpin[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$jingpin[$k]['time'])."分钟前"; 
					 }else{
					  	 if(date("Ymd",$jingpin[$k]['time'])==date("Ymd",time())){
							 $jingpin[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$jingpin[$k]['time'])."小时前"; 
						 }else{
							 if(date("Y",$jingpin[$k]['time'])==date("Y",time())){
						 		 $jingpin[$k]['fabushijian']=date("m月d日 H:i",$jingpin[$k]['time']);
							 }else{
								 $jingpin[$k]['fabushijian']=date("Y年m月d日 H:i",$jingpin[$k]['time']);
							 }
						 } 
					 }
				 }
				 //时间格式转换结束
				 
				 if($jingpin[$k]['jiajing']=="1"){
					 $jingpin[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
				 }else{
					 $jingpin[$k]['jingpinbiaozhi']="";
				 }
				 if($jingpin[$k]['tuijian']=="1"){
					 $jingpin[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
				 }else{
					 $jingpin[$k]['tuijianbiaozhi']="";
				 }
			 }	
			
		}else{
		 import("@.ORG.Page");
		 	$count	= M('weibo')->where("zhuanfazhe=0 and tuijian=1 and pindao=$pindaoid and $nowtime-time<60*60*24")->count();
			$Page	= New Page($count,6);
			$show	= $Page->show();
			
			
			$jingpin = M('weibo')->where("zhuanfazhe=0 and tuijian=1 and pindao=$pindaoid and $nowtime-time<60*60*24")->order('ttime desc,jtime desc')->limit($Page->firstRow.','.$Page->listRows)->select();
	         foreach($jingpin as $k=>$v){
				foreach($jingpin[$k] as $ks=>$vs){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$jingpin[$k][$ks]=stripslashes($vs); 
					} 
				}
					$jingpin[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
						foreach($jingpin[$k]['pinglun'] as $kk=>$vv){
							$fasongzhe=M('user')->find($vv['fasongzhe']);
							$jingpin[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
							$jingpin[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
							$jingpin[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
							foreach($jingpin[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
								$nicheng=M('user')->find($vvv['fasongzhe']);
								$jingpin[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
								$jingpin[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
							}
						}

				 
				 $zuozhe=M('user')->find($v['zuozhe']);
				 $jingpin[$k]['user_name']=$zuozhe['nicheng'];
				 $jingpin[$k]['user_touxiang']=$zuozhe['touxiang'];
				 $jingpin[$k]['user_id']=$zuozhe['id'];
				 //时间格式转换开始			 
				 if(date("YmdHi",$jingpin[$k]['time'])==date("YmdHi",time())){
				 	 $jingpin[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$jingpin[$k]['time'])."秒前";	 
				 }else{
					 if(date("YmdH",$jingpin[$k]['time'])==date("YmdH",time())){
						 $jingpin[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$jingpin[$k]['time'])."分钟前"; 
					 }else{
					  	 if(date("Ymd",$jingpin[$k]['time'])==date("Ymd",time())){
							 $jingpin[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$jingpin[$k]['time'])."小时前"; 
						 }else{
							 if(date("Y",$jingpin[$k]['time'])==date("Y",time())){
						 		 $jingpin[$k]['fabushijian']=date("m月d日 H:i",$jingpin[$k]['time']);
							 }else{
								 $jingpin[$k]['fabushijian']=date("Y年m月d日 H:i",$jingpin[$k]['time']);
							 }
						 } 
					 }
				 }
				 //时间格式转换结束

				 if($jingpin[$k]['jiajing']=="1"){
					 $jingpin[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
				 }else{
					 $jingpin[$k]['jingpinbiaozhi']="";
				 }
				 if($jingpin[$k]['tuijian']=="1"){
					 $jingpin[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
				 }else{
					 $jingpin[$k]['tuijianbiaozhi']="";
				 }
			 }
		}
	 		 
		 $this->assign('jingpin',$jingpin);
		 $this->assign('page',$show);
		 		 
		//热门微博列表

		if($pindaoid==""){
		 import("@.ORG.Page");
		 	$count2	= M('weibo')->where("zhuanfazhe=0 and $nowtime-time<60*60*24")->count();
			$Page2	= New Page($count2,6);
			$show2	= $Page2->show();
			
			
			$remen = M('weibo')->where("zhuanfazhe=0 and $nowtime-time<60*60*24")->order('yuedushu+zanshu+caishu desc')->limit($Page2->firstRow.','.$Page2->listRows)->select();
	         foreach($remen as $k=>$v){
				foreach($remen[$k] as $ks=>$vs){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$remen[$k][$ks]=stripslashes($vs); 
					} 
				}
					$remen[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
						foreach($remen[$k]['pinglun'] as $kk=>$vv){
							$fasongzhe=M('user')->find($vv['fasongzhe']);
							$remen[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
							$remen[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
							$remen[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
							foreach($remen[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
								$nicheng=M('user')->find($vvv['fasongzhe']);
								$remen[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
								$remen[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
							}
						}

				 
				 $zuozhe=M('user')->find($v['zuozhe']);
				 $remen[$k]['user_name']=$zuozhe['nicheng'];
				 $remen[$k]['user_touxiang']=$zuozhe['touxiang'];
				 $remen[$k]['user_id']=$zuozhe['id'];
				 //时间格式转换开始			 
				 if(date("YmdHi",$remen[$k]['time'])==date("YmdHi",time())){
				 	 $remen[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$remen[$k]['time'])."秒前";	 
				 }else{
					 if(date("YmdH",$remen[$k]['time'])==date("YmdH",time())){
						 $remen[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$remen[$k]['time'])."分钟前"; 
					 }else{
					  	 if(date("Ymd",$remen[$k]['time'])==date("Ymd",time())){
							 $remen[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$remen[$k]['time'])."小时前"; 
						 }else{
							 if(date("Y",$remen[$k]['time'])==date("Y",time())){
						 		 $remen[$k]['fabushijian']=date("m月d日 H:i",$remen[$k]['time']);
							 }else{
								 $remen[$k]['fabushijian']=date("Y年m月d日 H:i",$remen[$k]['time']);
							 }
						 } 
					 }
				 }
				 //时间格式转换结束

				 if($remen[$k]['jiajing']=="1"){
					 $remen[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
				 }else{
					 $remen[$k]['jingpinbiaozhi']="";
				 }
				 if($remen[$k]['tuijian']=="1"){
					 $remen[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
				 }else{
					 $remen[$k]['tuijianbiaozhi']="";
				 }
			 }	
			
		}else{
		 import("@.ORG.Page");
		 	$count2	= M('weibo')->where("zhuanfazhe=0 and $nowtime-time<60*60*24 and pindao=$pindaoid")->count();
			$Page2	= New Page($count2,6);
			$show2	= $Page2->show();
			
			
			$remen = M('weibo')->where("zhuanfazhe=0 and $nowtime-time<60*60*24 and pindao=$pindaoid")->order('yuedushu+zanshu+caishu desc')->limit($Page2->firstRow.','.$Page2->listRows)->select();
	         foreach($remen as $k=>$v){
				foreach($remen[$k] as $ks=>$vs){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$remen[$k][$ks]=stripslashes($vs); 
					} 
				}
					$remen[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
						foreach($remen[$k]['pinglun'] as $kk=>$vv){
							$fasongzhe=M('user')->find($vv['fasongzhe']);
							$remen[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
							$remen[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
							$remen[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
							foreach($remen[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
								$nicheng=M('user')->find($vvv['fasongzhe']);
								$remen[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
								$remen[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
							}
						}

				 
				 $zuozhe=M('user')->find($v['zuozhe']);
				 $remen[$k]['user_name']=$zuozhe['nicheng'];
				 $remen[$k]['user_touxiang']=$zuozhe['touxiang'];
				 $remen[$k]['user_id']=$zuozhe['id'];
				 //时间格式转换开始			 
				 if(date("YmdHi",$remen[$k]['time'])==date("YmdHi",time())){
				 	 $remen[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$remen[$k]['time'])."秒前";	 
				 }else{
					 if(date("YmdH",$remen[$k]['time'])==date("YmdH",time())){
						 $remen[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$remen[$k]['time'])."分钟前"; 
					 }else{
					  	 if(date("Ymd",$remen[$k]['time'])==date("Ymd",time())){
							 $remen[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$remen[$k]['time'])."小时前"; 
						 }else{
							 if(date("Y",$remen[$k]['time'])==date("Y",time())){
						 		 $remen[$k]['fabushijian']=date("m月d日 H:i",$remen[$k]['time']);
							 }else{
								 $remen[$k]['fabushijian']=date("Y年m月d日 H:i",$remen[$k]['time']);
							 }
						 } 
					 }
				 }
				 //时间格式转换结束

				 if($remen[$k]['jiajing']=="1"){
					 $remen[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
				 }else{
					 $remen[$k]['jingpinbiaozhi']="";
				 }
				 if($remen[$k]['tuijian']=="1"){
					 $remen[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
				 }else{
					 $remen[$k]['tuijianbiaozhi']="";
				 }
			 }
		}
	 
		 $this->assign('remen',$remen);
		 $this->assign('page2',$show2);		 
		 
		//最新微博列表

		if($pindaoid==""){
		 import("@.ORG.Page");
		 	$count3	= M('weibo')->where("zhuanfazhe=0 and $nowtime-time<60*60*24")->count();
			$Page3	= New Page($count3,6);
			$show3	= $Page3->show();
			
			
			$zuixin = M('weibo')->where("zhuanfazhe=0 and $nowtime-time<60*60*24")->order('time desc')->limit($Page3->firstRow.','.$Page3->listRows)->select();
	         foreach($zuixin as $k=>$v){
				foreach($zuixin[$k] as $ks=>$vs){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$zuixin[$k][$ks]=stripslashes($vs); 
					} 
				}
					$zuixin[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
						foreach($zuixin[$k]['pinglun'] as $kk=>$vv){
							$fasongzhe=M('user')->find($vv['fasongzhe']);
							$zuixin[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
							$zuixin[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
							$zuixin[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
							foreach($zuixin[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
								$nicheng=M('user')->find($vvv['fasongzhe']);
								$zuixin[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
								$zuixin[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
							}
						}

				 
				 $zuozhe=M('user')->find($v['zuozhe']);
				 $zuixin[$k]['user_name']=$zuozhe['nicheng'];
				 $zuixin[$k]['user_touxiang']=$zuozhe['touxiang'];
				 $zuixin[$k]['user_id']=$zuozhe['id'];
				 //时间格式转换开始			 
				 if(date("YmdHi",$zuixin[$k]['time'])==date("YmdHi",time())){
				 	 $zuixin[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$zuixin[$k]['time'])."秒前";	 
				 }else{
					 if(date("YmdH",$zuixin[$k]['time'])==date("YmdH",time())){
						 $zuixin[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$zuixin[$k]['time'])."分钟前"; 
					 }else{
					  	 if(date("Ymd",$zuixin[$k]['time'])==date("Ymd",time())){
							 $zuixin[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$zuixin[$k]['time'])."小时前"; 
						 }else{
							 if(date("Y",$zuixin[$k]['time'])==date("Y",time())){
						 		 $zuixin[$k]['fabushijian']=date("m月d日 H:i",$zuixin[$k]['time']);
							 }else{
								 $zuixin[$k]['fabushijian']=date("Y年m月d日 H:i",$zuixin[$k]['time']);
							 }
						 } 
					 }
				 }
				 //时间格式转换结束

				 if($zuixin[$k]['jiajing']=="1"){
					 $zuixin[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
				 }else{
					 $zuixin[$k]['jingpinbiaozhi']="";
				 }
				 if($zuixin[$k]['tuijian']=="1"){
					 $zuixin[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
				 }else{
					 $zuixin[$k]['tuijianbiaozhi']="";
				 }
			 }	
			
		}else{
		 import("@.ORG.Page");
		 	$count3	= M('weibo')->where("zhuanfazhe=0 and $nowtime-time<60*60*24 and pindao=$pindaoid")->count();
			$Page3	= New Page($count3,6);
			$show3	= $Page3->show();
			
			
			$zuixin = M('weibo')->where("zhuanfazhe=0 and $nowtime-time<60*60*24 and pindao=$pindaoid")->order('time desc')->limit($Page3->firstRow.','.$Page3->listRows)->select();
	         foreach($zuixin as $k=>$v){
				foreach($zuixin[$k] as $ks=>$vs){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$zuixin[$k][$ks]=stripslashes($vs); 
					} 
				}
					$zuixin[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
						foreach($zuixin[$k]['pinglun'] as $kk=>$vv){
							$fasongzhe=M('user')->find($vv['fasongzhe']);
							$zuixin[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
							$zuixin[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
							$zuixin[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
							foreach($zuixin[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
								$nicheng=M('user')->find($vvv['fasongzhe']);
								$zuixin[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
								$zuixin[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
							}
						}

				 
				 $zuozhe=M('user')->find($v['zuozhe']);
				 $zuixin[$k]['user_name']=$zuozhe['nicheng'];
				 $zuixin[$k]['user_touxiang']=$zuozhe['touxiang'];
				 $zuixin[$k]['user_id']=$zuozhe['id'];
				 //时间格式转换开始			 
				 if(date("YmdHi",$zuixin[$k]['time'])==date("YmdHi",time())){
				 	 $zuixin[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$zuixin[$k]['time'])."秒前";	 
				 }else{
					 if(date("YmdH",$zuixin[$k]['time'])==date("YmdH",time())){
						 $zuixin[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$zuixin[$k]['time'])."分钟前"; 
					 }else{
					  	 if(date("Ymd",$zuixin[$k]['time'])==date("Ymd",time())){
							 $zuixin[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$zuixin[$k]['time'])."小时前"; 
						 }else{
							 if(date("Y",$zuixin[$k]['time'])==date("Y",time())){
						 		 $zuixin[$k]['fabushijian']=date("m月d日 H:i",$zuixin[$k]['time']);
							 }else{
								 $zuixin[$k]['fabushijian']=date("Y年m月d日 H:i",$zuixin[$k]['time']);
							 }
						 } 
					 }
				 }
				 //时间格式转换结束

				 if($zuixin[$k]['jiajing']=="1"){
					 $zuixin[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
				 }else{
					 $zuixin[$k]['jingpinbiaozhi']="";
				 }
				 if($zuixin[$k]['tuijian']=="1"){
					 $zuixin[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
				 }else{
					 $zuixin[$k]['tuijianbiaozhi']="";
				 }
			 }
		}	 
		 $this->assign('zuixin',$zuixin);
		 $this->assign('page3',$show3);		 
		 //达人推荐
		 $darentuijian = M('user')->where("shoutuijian=1")->order('stime desc')->limit('0,4')->select();
		 $this->assign('darentuijian',$darentuijian);
		 
	     //小喇叭下面左侧轮播
		 $xiaolabaxiazuolunbo1 = M('guanggaowei')->find(2);
		 $this->assign('xiaolabaxiazuolunbo1',$xiaolabaxiazuolunbo1);
		 $xiaolabaxiazuolunbo2 = M('guanggaowei')->find(3);
		 $this->assign('xiaolabaxiazuolunbo2',$xiaolabaxiazuolunbo2);
		 $xiaolabaxiazuolunbo3 = M('guanggaowei')->find(4);
		 $this->assign('xiaolabaxiazuolunbo3',$xiaolabaxiazuolunbo3);
		 $xiaolabaxiazuolunbo4 = M('guanggaowei')->find(5);
		 $this->assign('xiaolabaxiazuolunbo4',$xiaolabaxiazuolunbo4);
		 $xiaolabaxiazuolunbo5 = M('guanggaowei')->find(6);
		 $this->assign('xiaolabaxiazuolunbo5',$xiaolabaxiazuolunbo5);
		 $xiaolabaxiazuolunbo6 = M('guanggaowei')->find(7);
		 $this->assign('xiaolabaxiazuolunbo6',$xiaolabaxiazuolunbo6);
	     //小喇叭下面右侧广告位
		 $xiaolabaxiayouguanggaowei = M('guanggaowei')->find(8);
		 $this->assign('xiaolabaxiayouguanggaowei',$xiaolabaxiayouguanggaowei);
	     //精品图片上面左侧广告位
		 $jingpintupianshangzuoguanggaowei = M('guanggaowei')->find(9);
		 $this->assign('jingpintupianshangzuoguanggaowei',$jingpintupianshangzuoguanggaowei);
	     //精品图片上面右侧广告位
		 $jingpintupianshangyouguanggaowei1 = M('guanggaowei')->find(10);
		 $this->assign('jingpintupianshangyouguanggaowei1',$jingpintupianshangyouguanggaowei1);
		 $jingpintupianshangyouguanggaowei2 = M('guanggaowei')->find(11);
		 $this->assign('jingpintupianshangyouguanggaowei2',$jingpintupianshangyouguanggaowei2);
		 $jingpintupianshangyouguanggaowei3 = M('guanggaowei')->find(12);
		 $this->assign('jingpintupianshangyouguanggaowei3',$jingpintupianshangyouguanggaowei3);
		 $jingpintupianshangyouguanggaowei4 = M('guanggaowei')->find(13);
		 $this->assign('jingpintupianshangyouguanggaowei4',$jingpintupianshangyouguanggaowei4);
		 //精品图片
		 $jingpintupian1 = M('guanggaowei')->find(14);
		 $this->assign('jingpintupian1',$jingpintupian1);
		 $jingpintupian2 = M('guanggaowei')->find(15);
		 $this->assign('jingpintupian2',$jingpintupian2);
		 $jingpintupian3 = M('guanggaowei')->find(16);
		 $this->assign('jingpintupian3',$jingpintupian3);
		 $jingpintupian4 = M('guanggaowei')->find(17);
		 $this->assign('jingpintupian4',$jingpintupian4);
		 $jingpintupian5 = M('guanggaowei')->find(18);
		 $this->assign('jingpintupian5',$jingpintupian5);
		 $jingpintupian6 = M('guanggaowei')->find(19);
		 $this->assign('jingpintupian6',$jingpintupian6);
		 $jingpintupian7 = M('guanggaowei')->find(20);
		 $this->assign('jingpintupian7',$jingpintupian7);
		 $jingpintupian8 = M('guanggaowei')->find(21);
		 $this->assign('jingpintupian8',$jingpintupian8);
		 $jingpintupian9 = M('guanggaowei')->find(22);
		 $this->assign('jingpintupian9',$jingpintupian9);
		 $jingpintupian10 = M('guanggaowei')->find(23);
		 $this->assign('jingpintupian10',$jingpintupian10);
		 $jingpintupian11 = M('guanggaowei')->find(24);
		 $this->assign('jingpintupian11',$jingpintupian11);
		 $jingpintupian12 = M('guanggaowei')->find(25);
		 $this->assign('jingpintupian12',$jingpintupian12);
		 //友情链接
		 $youqinglianjie1 = M('youlian')->order('xu asc,id asc')->limit('0,1')->select();
		 $this->assign('youqinglianjie1',$youqinglianjie1);
		 $youqinglianjie2 = M('youlian')->order('xu asc,id asc')->limit('1,9')->select();
		 $this->assign('youqinglianjie2',$youqinglianjie2);
		 $youqinglianjie3 = M('youlian')->order('xu asc,id asc')->limit('10,1')->select();
		 $this->assign('youqinglianjie3',$youqinglianjie3);
		 $youqinglianjie4 = M('youlian')->order('xu asc,id asc')->limit('11,9')->select();
		 $this->assign('youqinglianjie4',$youqinglianjie4);

		 $this->display();
	 }
	//首页转发微博jingpin
	function dozhuanfaweibojingpin(){
	    header("Content-Type:text/html; charset=utf-8");

		$zhuanfa['time']=time();
		$zhuanfa['zhuanfazhe']=$_SESSION['user_id'];
		$weiboid=$_POST['weibo_id'];
		$yuanweibo=M('weibo')->find($weiboid);
		$zhuanfa['zuozhe']=$_SESSION['user_id'];
		$zhuanfa['content']=$_POST['content'];		
		$zhuanfa['yuedushu']="0";
		$zhuanfa['zanshu']="0";
		$zhuanfa['caishu']="0";
		$zhuanfa['pindao']=$yuanweibo['pindao'];
		$zhuanfa['tuijian']="0";
		$zhuanfa['jiajing']="0";
		$zhuanfa['wenzilian']="0";
		$zhuanfa['ttime']="0";
		$zhuanfa['jtime']="0";
		$zhuanfa['wtime']="0";
		$zhuanfa['wenzi']="";
		$zhuanfa['zhiding']="0";
		$zhuanfa['zhitime']="0";
		$zhuanfa['suoshuweibo_id']=$yuanweibo['id'];
		$zhuanfa['suoshuzuozhe_id']=$yuanweibo['zuozhe'];
			
		if($zhuanfa['zhuanfazhe']=='0' || $zhuanfa['zuozhe']=='0' || $zhuanfa['suoshuweibo_id']=='0' ){
			$this->error("信息不完整");	
		}
		if($_SESSION['user_id']!=""){
			  if( M('weibo')->add($zhuanfa) ){
					$useryuan=M('user')->find($_SESSION['user_id']);  
					if($useryuan['zhuanfacishu']>=1){
						$user['id']=$_SESSION['user_id'];
						$user['zhuanfacishu']=$useryuan['zhuanfacishu']-1;
						$user['jifen']=$useryuan['jifen']+1;
						M('user')->save($user);
					}	
					$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
					$this->success('转发成功！');
			  }else{
					$this->error('转发失败！');
			  }
		}else{
			$this->error("请登录");	
		}
		
	}
	//首页转发微博remen
	function dozhuanfaweiboremen(){
	    header("Content-Type:text/html; charset=utf-8");

		$zhuanfa['time']=time();
		$zhuanfa['zhuanfazhe']=$_SESSION['user_id'];
		$weiboid=$_POST['weibo_id'];
		$yuanweibo=M('weibo')->find($weiboid);
		$zhuanfa['zuozhe']=$_SESSION['user_id'];
		$zhuanfa['content']=$_POST['content'];		
		$zhuanfa['yuedushu']="0";
		$zhuanfa['zanshu']="0";
		$zhuanfa['caishu']="0";
		$zhuanfa['pindao']=$yuanweibo['pindao'];
		$zhuanfa['tuijian']="0";
		$zhuanfa['jiajing']="0";
		$zhuanfa['wenzilian']="0";
		$zhuanfa['ttime']="0";
		$zhuanfa['jtime']="0";
		$zhuanfa['wtime']="0";
		$zhuanfa['wenzi']="";
		$zhuanfa['zhiding']="0";
		$zhuanfa['zhitime']="0";
		$zhuanfa['suoshuweibo_id']=$yuanweibo['id'];
		$zhuanfa['suoshuzuozhe_id']=$yuanweibo['zuozhe'];
			
		if($zhuanfa['zhuanfazhe']=='0' || $zhuanfa['zuozhe']=='0' || $zhuanfa['suoshuweibo_id']=='0' ){
			$this->error("信息不完整");	
		}
		if($_SESSION['user_id']!=""){
			  if( M('weibo')->add($zhuanfa) ){
					$useryuan=M('user')->find($_SESSION['user_id']);  
					if($useryuan['zhuanfacishu']>=1){
						$user['id']=$_SESSION['user_id'];
						$user['zhuanfacishu']=$useryuan['zhuanfacishu']-1;
						$user['jifen']=$useryuan['jifen']+1;
						M('user')->save($user);
					}	
					$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
					$this->success('转发成功！');
			  }else{
					$this->error('转发失败！');
			  }
		}else{
			$this->error("请登录");	
		}
		
	}
	//首页转发微博zuixin
	function dozhuanfaweibozuixin(){
	    header("Content-Type:text/html; charset=utf-8");

		$zhuanfa['time']=time();
		$zhuanfa['zhuanfazhe']=$_SESSION['user_id'];
		$weiboid=$_POST['weibo_id'];
		$yuanweibo=M('weibo')->find($weiboid);
		$zhuanfa['zuozhe']=$_SESSION['user_id'];
		$zhuanfa['content']=$_POST['content'];		
		$zhuanfa['yuedushu']="0";
		$zhuanfa['zanshu']="0";
		$zhuanfa['caishu']="0";
		$zhuanfa['pindao']=$yuanweibo['pindao'];
		$zhuanfa['tuijian']="0";
		$zhuanfa['jiajing']="0";
		$zhuanfa['wenzilian']="0";
		$zhuanfa['ttime']="0";
		$zhuanfa['jtime']="0";
		$zhuanfa['wtime']="0";
		$zhuanfa['wenzi']="";
		$zhuanfa['zhiding']="0";
		$zhuanfa['zhitime']="0";
		$zhuanfa['suoshuweibo_id']=$yuanweibo['id'];
		$zhuanfa['suoshuzuozhe_id']=$yuanweibo['zuozhe'];
			
		if($zhuanfa['zhuanfazhe']=='0' || $zhuanfa['zuozhe']=='0' || $zhuanfa['suoshuweibo_id']=='0' ){
			$this->error("信息不完整");	
		}
		if($_SESSION['user_id']!=""){
			  if( M('weibo')->add($zhuanfa) ){
					$useryuan=M('user')->find($_SESSION['user_id']);  
					if($useryuan['zhuanfacishu']>=1){
						$user['id']=$_SESSION['user_id'];
						$user['zhuanfacishu']=$useryuan['zhuanfacishu']-1;
						$user['jifen']=$useryuan['jifen']+1;
						M('user')->save($user);
					}	
					$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
					$this->success('转发成功！');
			  }else{
					$this->error('转发失败！');
			  }
		}else{
			$this->error("请登录");	
		}
		
	}
	 
	//首页发评论2
	function dopingluns2(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['time']=time();
		$_POST['fasongzhe']=$_SESSION['user_id'];
		$fasong=$_POST['weibo_id'];
		$fasongid=M('weibo')->find($fasong);
		$_POST['jieshouzhe']=$fasongid['zuozhe'];
		$_POST['pinglun_id']="0";
		if($_POST['content']==''){
			$this->error("信息不完整");	
		}
		if($_SESSION['user_id']==""){
			$this->error("请登录");	
		}else{
			$zuozhepinglunshezhi=M('user')->find($fasongid['zuozhe']);
			if($zuozhepinglunshezhi['pinglunshezhi']==0){
				if( M('pinglun')->add($_POST) ){
					$useryuan=M('user')->find($_SESSION['user_id']);  
					if($useryuan['pingluncishu']>=1){
						$user['id']=$_SESSION['user_id'];
						$user['pingluncishu']=$useryuan['pingluncishu']-1;
						$user['jifen']=$useryuan['jifen']+1;
						M('user')->save($user);
					}	
				  
					$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
					$this->success('评论成功！');
				}else{
					$this->error('评论失败！');
				}	
			}else{
				if($zuozhepinglunshezhi['pinglunshezhi']==1){
					$zhurenid=$fasongid['zuozhe'];
					$pinglunzheid=$_SESSION['user_id'];
					$haoyou = M('haoyou')->where("zhu_id=$zhurenid and bei_id=$pinglunzheid")->select();
					if($haoyou){
						if( M('pinglun')->add($_POST) ){
							$useryuan=M('user')->find($_SESSION['user_id']);  
							if($useryuan['pingluncishu']>=1){
								$user['id']=$_SESSION['user_id'];
								$user['pingluncishu']=$useryuan['pingluncishu']-1;
								$user['jifen']=$useryuan['jifen']+1;
								M('user')->save($user);
							}	
						  
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->success('评论成功！');
						}else{
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->error('评论失败！');
						}
					}else{
						$this->error('主人设置仅好友可以评论');
					}
				}else{
					if($_POST['fasongzhe']==$fasongid['zuozhe']){
						if( M('pinglun')->add($_POST) ){
							$useryuan=M('user')->find($_SESSION['user_id']);  
							if($useryuan['pingluncishu']>=1){
								$user['id']=$_SESSION['user_id'];
								$user['pingluncishu']=$useryuan['pingluncishu']-1;
								$user['jifen']=$useryuan['jifen']+1;
								M('user')->save($user);
							}	
						  
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->success('评论成功！');
						}else{
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->error('评论失败！');
						}
					}else{
						$this->error('主人设置仅自己可以评论');
					}

				}
			
			}


		}
	}	
	//首页发评论回复2
	function dogrwbsypinglunhuifus2(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['time']=time();
		$_POST['fasongzhe']=$_SESSION['user_id'];
		$fasong=$_POST['pinglun_id'];
		$fasongid=M('pinglun')->find($fasong);
		$_POST['jieshouzhe']=$fasongid['fasongzhe'];
		$_POST['weibo_id']=$fasongid['weibo_id'];
		if($_POST['content']==''){
			$this->error("信息不完整");	
		}
		if($_SESSION['user_id']==""){
			$this->error("请登录");	
		}else{
			$zuozhepinglunshezhi=M('user')->find($fasongid['zuozhe']);
			if($zuozhepinglunshezhi['pinglunshezhi']==0){
				if( M('pinglun')->add($_POST) ){
					$useryuan=M('user')->find($_SESSION['user_id']);  
					if($useryuan['pingluncishu']>=1){
						$user['id']=$_SESSION['user_id'];
						$user['pingluncishu']=$useryuan['pingluncishu']-1;
						$user['jifen']=$useryuan['jifen']+1;
						M('user')->save($user);
					}	
				  
					$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
					$this->success('评论成功！');
				}else{
					$this->error('评论失败！');
				}	
			}else{
				if($zuozhepinglunshezhi['pinglunshezhi']==1){
					$zhurenid=$fasongid['zuozhe'];
					$pinglunzheid=$_SESSION['user_id'];
					$haoyou = M('haoyou')->where("zhu_id=$zhurenid and bei_id=$pinglunzheid")->select();
					if($haoyou){
						if( M('pinglun')->add($_POST) ){
							$useryuan=M('user')->find($_SESSION['user_id']);  
							if($useryuan['pingluncishu']>=1){
								$user['id']=$_SESSION['user_id'];
								$user['pingluncishu']=$useryuan['pingluncishu']-1;
								$user['jifen']=$useryuan['jifen']+1;
								M('user')->save($user);
							}	
						  
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->success('评论成功！');
						}else{
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->error('评论失败！');
						}
					}else{
						$this->error('主人设置仅好友可以评论');
					}
				}else{
					if($_POST['fasongzhe']==$fasongid['zuozhe']){
						if( M('pinglun')->add($_POST) ){
							$useryuan=M('user')->find($_SESSION['user_id']);  
							if($useryuan['pingluncishu']>=1){
								$user['id']=$_SESSION['user_id'];
								$user['pingluncishu']=$useryuan['pingluncishu']-1;
								$user['jifen']=$useryuan['jifen']+1;
								M('user')->save($user);
							}	
						  
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->success('评论成功！');
						}else{
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->error('评论失败！');
						}
					}else{
						$this->error('主人设置仅自己可以评论');
					}

				}
			
			}


		}
}
	//首页发评论3
	function dopingluns3(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['time']=time();
		$_POST['fasongzhe']=$_SESSION['user_id'];
		$fasong=$_POST['weibo_id'];
		$fasongid=M('weibo')->find($fasong);
		$_POST['jieshouzhe']=$fasongid['zuozhe'];
		$_POST['pinglun_id']="0";
		if($_POST['content']==''){
			$this->error("信息不完整");	
		}
		if($_SESSION['user_id']==""){
			$this->error("请登录");	
		}else{
			$zuozhepinglunshezhi=M('user')->find($fasongid['zuozhe']);
			if($zuozhepinglunshezhi['pinglunshezhi']==0){
				if( M('pinglun')->add($_POST) ){
					$useryuan=M('user')->find($_SESSION['user_id']);  
					if($useryuan['pingluncishu']>=1){
						$user['id']=$_SESSION['user_id'];
						$user['pingluncishu']=$useryuan['pingluncishu']-1;
						$user['jifen']=$useryuan['jifen']+1;
						M('user')->save($user);
					}	
				  
					$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
					$this->success('评论成功！');
				}else{
					$this->error('评论失败！');
				}	
			}else{
				if($zuozhepinglunshezhi['pinglunshezhi']==1){
					$zhurenid=$fasongid['zuozhe'];
					$pinglunzheid=$_SESSION['user_id'];
					$haoyou = M('haoyou')->where("zhu_id=$zhurenid and bei_id=$pinglunzheid")->select();
					if($haoyou){
						if( M('pinglun')->add($_POST) ){
							$useryuan=M('user')->find($_SESSION['user_id']);  
							if($useryuan['pingluncishu']>=1){
								$user['id']=$_SESSION['user_id'];
								$user['pingluncishu']=$useryuan['pingluncishu']-1;
								$user['jifen']=$useryuan['jifen']+1;
								M('user')->save($user);
							}	
						  
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->success('评论成功！');
						}else{
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->error('评论失败！');
						}
					}else{
						$this->error('主人设置仅好友可以评论');
					}
				}else{
					if($_POST['fasongzhe']==$fasongid['zuozhe']){
						if( M('pinglun')->add($_POST) ){
							$useryuan=M('user')->find($_SESSION['user_id']);  
							if($useryuan['pingluncishu']>=1){
								$user['id']=$_SESSION['user_id'];
								$user['pingluncishu']=$useryuan['pingluncishu']-1;
								$user['jifen']=$useryuan['jifen']+1;
								M('user')->save($user);
							}	
						  
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->success('评论成功！');
						}else{
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->error('评论失败！');
						}
					}else{
						$this->error('主人设置仅自己可以评论');
					}

				}
			
			}


		}
}	
	//首页发评论回复3
	function dogrwbsypinglunhuifus3(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['time']=time();
		$_POST['fasongzhe']=$_SESSION['user_id'];
		$fasong=$_POST['pinglun_id'];
		$fasongid=M('pinglun')->find($fasong);
		$_POST['jieshouzhe']=$fasongid['fasongzhe'];
		$_POST['weibo_id']=$fasongid['weibo_id'];
		if($_POST['content']==''){
			$this->error("信息不完整");	
		}
		if($_SESSION['user_id']==""){
			$this->error("请登录");	
		}else{
			$zuozhepinglunshezhi=M('user')->find($fasongid['zuozhe']);
			if($zuozhepinglunshezhi['pinglunshezhi']==0){
				if( M('pinglun')->add($_POST) ){
					$useryuan=M('user')->find($_SESSION['user_id']);  
					if($useryuan['pingluncishu']>=1){
						$user['id']=$_SESSION['user_id'];
						$user['pingluncishu']=$useryuan['pingluncishu']-1;
						$user['jifen']=$useryuan['jifen']+1;
						M('user')->save($user);
					}	
				  
					$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
					$this->success('评论成功！');
				}else{
					$this->error('评论失败！');
				}	
			}else{
				if($zuozhepinglunshezhi['pinglunshezhi']==1){
					$zhurenid=$fasongid['zuozhe'];
					$pinglunzheid=$_SESSION['user_id'];
					$haoyou = M('haoyou')->where("zhu_id=$zhurenid and bei_id=$pinglunzheid")->select();
					if($haoyou){
						if( M('pinglun')->add($_POST) ){
							$useryuan=M('user')->find($_SESSION['user_id']);  
							if($useryuan['pingluncishu']>=1){
								$user['id']=$_SESSION['user_id'];
								$user['pingluncishu']=$useryuan['pingluncishu']-1;
								$user['jifen']=$useryuan['jifen']+1;
								M('user')->save($user);
							}	
						  
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->success('评论成功！');
						}else{
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->error('评论失败！');
						}
					}else{
						$this->error('主人设置仅好友可以评论');
					}
				}else{
					if($_POST['fasongzhe']==$fasongid['zuozhe']){
						if( M('pinglun')->add($_POST) ){
							$useryuan=M('user')->find($_SESSION['user_id']);  
							if($useryuan['pingluncishu']>=1){
								$user['id']=$_SESSION['user_id'];
								$user['pingluncishu']=$useryuan['pingluncishu']-1;
								$user['jifen']=$useryuan['jifen']+1;
								M('user')->save($user);
							}	
						  
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->success('评论成功！');
						}else{
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->error('评论失败！');
						}
					}else{
						$this->error('主人设置仅自己可以评论');
					}

				}
			
			}


		}
}
	function rmpd(){
		//频道列表
		$pindao = M('pindao')->order('id asc')->select();
		$this->assign('pindao',$pindao);
		//精品推荐列表
		
		$pindaoid=$_GET["pindaoid"];
		$nowtime=time();
		if($pindaoid==""){
		 import("@.ORG.Page");
		 	$count	= M('weibo')->where("zhuanfazhe=0 and tuijian=1 and $nowtime-time<60*60*24")->count();
			$Page	= New Page($count,12);
			$show	= $Page->show();
			
			
			$jingpin = M('weibo')->where("zhuanfazhe=0 and tuijian=1 and $nowtime-time<60*60*24")->order('ttime desc,jtime desc')->limit($Page->firstRow.','.$Page->listRows)->select();
	         foreach($jingpin as $k=>$v){
				foreach($jingpin[$k] as $ks=>$vs){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$jingpin[$k][$ks]=stripslashes($vs); 
					} 
				}
					$jingpin[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
						foreach($jingpin[$k]['pinglun'] as $kk=>$vv){
							$fasongzhe=M('user')->find($vv['fasongzhe']);
							$jingpin[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
							$jingpin[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
							$jingpin[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
							foreach($jingpin[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
								$nicheng=M('user')->find($vvv['fasongzhe']);
								$jingpin[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
								$jingpin[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
							}
						}
				 $pindaotupian=M('pindao')->find($v['pindao']);
				 $jingpin[$k]['pindao_tupian']=$pindaotupian['tupian'];

				 $zuozhe=M('user')->find($v['zuozhe']);
				 $jingpin[$k]['user_name']=$zuozhe['nicheng'];
				 $jingpin[$k]['user_touxiang']=$zuozhe['touxiang'];
				 $jingpin[$k]['user_id']=$zuozhe['id'];
				 //时间格式转换开始			 
				 if(date("YmdHi",$jingpin[$k]['time'])==date("YmdHi",time())){
				 	 $jingpin[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$jingpin[$k]['time'])."秒前";	 
				 }else{
					 if(date("YmdH",$jingpin[$k]['time'])==date("YmdH",time())){
						 $jingpin[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$jingpin[$k]['time'])."分钟前"; 
					 }else{
					  	 if(date("Ymd",$jingpin[$k]['time'])==date("Ymd",time())){
							 $jingpin[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$jingpin[$k]['time'])."小时前"; 
						 }else{
							 if(date("Y",$jingpin[$k]['time'])==date("Y",time())){
						 		 $jingpin[$k]['fabushijian']=date("m月d日 H:i",$jingpin[$k]['time']);
							 }else{
								 $jingpin[$k]['fabushijian']=date("Y年m月d日 H:i",$jingpin[$k]['time']);
							 }
						 } 
					 }
				 }
				 //时间格式转换结束
				 
				 if($jingpin[$k]['jiajing']=="1"){
					 $jingpin[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
				 }else{
					 $jingpin[$k]['jingpinbiaozhi']="";
				 }
				 if($jingpin[$k]['tuijian']=="1"){
					 $jingpin[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
				 }else{
					 $jingpin[$k]['tuijianbiaozhi']="";
				 }
			 }	
			
		}else{
		 import("@.ORG.Page");
		 	$count	= M('weibo')->where("zhuanfazhe=0 and tuijian=1 and pindao=$pindaoid and $nowtime-time<60*60*24")->count();
			$Page	= New Page($count,12);
			$show	= $Page->show();
			
			
			$jingpin = M('weibo')->where("zhuanfazhe=0 and tuijian=1 and pindao=$pindaoid and $nowtime-time<60*60*24")->order('ttime desc,jtime desc')->limit($Page->firstRow.','.$Page->listRows)->select();
	         foreach($jingpin as $k=>$v){
				foreach($jingpin[$k] as $ks=>$vs){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$jingpin[$k][$ks]=stripslashes($vs); 
					} 
				}
					$jingpin[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
						foreach($jingpin[$k]['pinglun'] as $kk=>$vv){
							$fasongzhe=M('user')->find($vv['fasongzhe']);
							$jingpin[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
							$jingpin[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
							$jingpin[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
							foreach($jingpin[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
								$nicheng=M('user')->find($vvv['fasongzhe']);
								$jingpin[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
								$jingpin[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
							}
						}
				 $pindaotupian=M('pindao')->find($v['pindao']);
				 $jingpin[$k]['pindao_tupian']=$pindaotupian['tupian'];
				 $zuozhe=M('user')->find($v['zuozhe']);
				 $jingpin[$k]['user_name']=$zuozhe['nicheng'];
				 $jingpin[$k]['user_touxiang']=$zuozhe['touxiang'];
				 $jingpin[$k]['user_id']=$zuozhe['id'];
				 //时间格式转换开始			 
				 if(date("YmdHi",$jingpin[$k]['time'])==date("YmdHi",time())){
				 	 $jingpin[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$jingpin[$k]['time'])."秒前";	 
				 }else{
					 if(date("YmdH",$jingpin[$k]['time'])==date("YmdH",time())){
						 $jingpin[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$jingpin[$k]['time'])."分钟前"; 
					 }else{
					  	 if(date("Ymd",$jingpin[$k]['time'])==date("Ymd",time())){
							 $jingpin[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$jingpin[$k]['time'])."小时前"; 
						 }else{
							 if(date("Y",$jingpin[$k]['time'])==date("Y",time())){
						 		 $jingpin[$k]['fabushijian']=date("m月d日 H:i",$jingpin[$k]['time']);
							 }else{
								 $jingpin[$k]['fabushijian']=date("Y年m月d日 H:i",$jingpin[$k]['time']);
							 }
						 } 
					 }
				 }
				 //时间格式转换结束

				 if($jingpin[$k]['jiajing']=="1"){
					 $jingpin[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
				 }else{
					 $jingpin[$k]['jingpinbiaozhi']="";
				 }
				 if($jingpin[$k]['tuijian']=="1"){
					 $jingpin[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
				 }else{
					 $jingpin[$k]['tuijianbiaozhi']="";
				 }
			 }
		}
	 		 
		 $this->assign('jingpin',$jingpin);
		 $this->assign('page',$show);
		 		 
		//热门微博列表

		if($pindaoid==""){
		 import("@.ORG.Page");
		 	$count2	= M('weibo')->where("zhuanfazhe=0 and $nowtime-time<60*60*24")->count();
			$Page2	= New Page($count2,12);
			$show2	= $Page2->show();
			
			
			$remen = M('weibo')->where("zhuanfazhe=0 and $nowtime-time<60*60*24")->order('yuedushu+zanshu+caishu desc')->limit($Page2->firstRow.','.$Page2->listRows)->select();
	         foreach($remen as $k=>$v){
				foreach($remen[$k] as $ks=>$vs){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$remen[$k][$ks]=stripslashes($vs); 
					} 
				}
					$remen[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
						foreach($remen[$k]['pinglun'] as $kk=>$vv){
							$fasongzhe=M('user')->find($vv['fasongzhe']);
							$remen[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
							$remen[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
							$remen[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
							foreach($remen[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
								$nicheng=M('user')->find($vvv['fasongzhe']);
								$remen[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
								$remen[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
							}
						}
				 $pindaotupian=M('pindao')->find($v['pindao']);
				 $remen[$k]['pindao_tupian']=$pindaotupian['tupian'];
				 $zuozhe=M('user')->find($v['zuozhe']);
				 $remen[$k]['user_name']=$zuozhe['nicheng'];
				 $remen[$k]['user_touxiang']=$zuozhe['touxiang'];
				 $remen[$k]['user_id']=$zuozhe['id'];
				 //时间格式转换开始			 
				 if(date("YmdHi",$remen[$k]['time'])==date("YmdHi",time())){
				 	 $remen[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$remen[$k]['time'])."秒前";	 
				 }else{
					 if(date("YmdH",$remen[$k]['time'])==date("YmdH",time())){
						 $remen[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$remen[$k]['time'])."分钟前"; 
					 }else{
					  	 if(date("Ymd",$remen[$k]['time'])==date("Ymd",time())){
							 $remen[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$remen[$k]['time'])."小时前"; 
						 }else{
							 if(date("Y",$remen[$k]['time'])==date("Y",time())){
						 		 $remen[$k]['fabushijian']=date("m月d日 H:i",$remen[$k]['time']);
							 }else{
								 $remen[$k]['fabushijian']=date("Y年m月d日 H:i",$remen[$k]['time']);
							 }
						 } 
					 }
				 }
				 //时间格式转换结束

				 if($remen[$k]['jiajing']=="1"){
					 $remen[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
				 }else{
					 $remen[$k]['jingpinbiaozhi']="";
				 }
				 if($remen[$k]['tuijian']=="1"){
					 $remen[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
				 }else{
					 $remen[$k]['tuijianbiaozhi']="";
				 }
			 }	
			
		}else{
		 import("@.ORG.Page");
		 	$count2	= M('weibo')->where("zhuanfazhe=0 and $nowtime-time<60*60*24 and pindao=$pindaoid")->count();
			$Page2	= New Page($count2,12);
			$show2	= $Page2->show();
			
			
			$remen = M('weibo')->where("zhuanfazhe=0 and $nowtime-time<60*60*24 and pindao=$pindaoid")->order('yuedushu+zanshu+caishu desc')->limit($Page2->firstRow.','.$Page2->listRows)->select();
	         foreach($remen as $k=>$v){
				foreach($remen[$k] as $ks=>$vs){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$remen[$k][$ks]=stripslashes($vs); 
					} 
				}
					$remen[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
						foreach($remen[$k]['pinglun'] as $kk=>$vv){
							$fasongzhe=M('user')->find($vv['fasongzhe']);
							$remen[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
							$remen[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
							$remen[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
							foreach($remen[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
								$nicheng=M('user')->find($vvv['fasongzhe']);
								$remen[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
								$remen[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
							}
						}
				 $pindaotupian=M('pindao')->find($v['pindao']);
				 $remen[$k]['pindao_tupian']=$pindaotupian['tupian'];
				 $zuozhe=M('user')->find($v['zuozhe']);
				 $remen[$k]['user_name']=$zuozhe['nicheng'];
				 $remen[$k]['user_touxiang']=$zuozhe['touxiang'];
				 $remen[$k]['user_id']=$zuozhe['id'];
				 //时间格式转换开始			 
				 if(date("YmdHi",$remen[$k]['time'])==date("YmdHi",time())){
				 	 $remen[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$remen[$k]['time'])."秒前";	 
				 }else{
					 if(date("YmdH",$remen[$k]['time'])==date("YmdH",time())){
						 $remen[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$remen[$k]['time'])."分钟前"; 
					 }else{
					  	 if(date("Ymd",$remen[$k]['time'])==date("Ymd",time())){
							 $remen[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$remen[$k]['time'])."小时前"; 
						 }else{
							 if(date("Y",$remen[$k]['time'])==date("Y",time())){
						 		 $remen[$k]['fabushijian']=date("m月d日 H:i",$remen[$k]['time']);
							 }else{
								 $remen[$k]['fabushijian']=date("Y年m月d日 H:i",$remen[$k]['time']);
							 }
						 } 
					 }
				 }
				 //时间格式转换结束

				 if($remen[$k]['jiajing']=="1"){
					 $remen[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
				 }else{
					 $remen[$k]['jingpinbiaozhi']="";
				 }
				 if($remen[$k]['tuijian']=="1"){
					 $remen[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
				 }else{
					 $remen[$k]['tuijianbiaozhi']="";
				 }
			 }
		}
	 
		 $this->assign('remen',$remen);
		 $this->assign('page2',$show2);		 
		 
		//最新微博列表

		if($pindaoid==""){
		 import("@.ORG.Page");
		 	$count3	= M('weibo')->where("zhuanfazhe=0 and $nowtime-time<60*60*24")->count();
			$Page3	= New Page($count3,12);
			$show3	= $Page3->show();
			
			
			$zuixin = M('weibo')->where("zhuanfazhe=0 and $nowtime-time<60*60*24")->order('time desc')->limit($Page3->firstRow.','.$Page3->listRows)->select();
	         foreach($zuixin as $k=>$v){
				foreach($zuixin[$k] as $ks=>$vs){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$zuixin[$k][$ks]=stripslashes($vs); 
					} 
				}
					$zuixin[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
						foreach($zuixin[$k]['pinglun'] as $kk=>$vv){
							$fasongzhe=M('user')->find($vv['fasongzhe']);
							$zuixin[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
							$zuixin[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
							$zuixin[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
							foreach($zuixin[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
								$nicheng=M('user')->find($vvv['fasongzhe']);
								$zuixin[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
								$zuixin[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
							}
						}
				 $pindaotupian=M('pindao')->find($v['pindao']);
				 $zuixin[$k]['pindao_tupian']=$pindaotupian['tupian'];
				 $zuozhe=M('user')->find($v['zuozhe']);
				 $zuixin[$k]['user_name']=$zuozhe['nicheng'];
				 $zuixin[$k]['user_touxiang']=$zuozhe['touxiang'];
				 $zuixin[$k]['user_id']=$zuozhe['id'];
				 //时间格式转换开始			 
				 if(date("YmdHi",$zuixin[$k]['time'])==date("YmdHi",time())){
				 	 $zuixin[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$zuixin[$k]['time'])."秒前";	 
				 }else{
					 if(date("YmdH",$zuixin[$k]['time'])==date("YmdH",time())){
						 $zuixin[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$zuixin[$k]['time'])."分钟前"; 
					 }else{
					  	 if(date("Ymd",$zuixin[$k]['time'])==date("Ymd",time())){
							 $zuixin[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$zuixin[$k]['time'])."小时前"; 
						 }else{
							 if(date("Y",$zuixin[$k]['time'])==date("Y",time())){
						 		 $zuixin[$k]['fabushijian']=date("m月d日 H:i",$zuixin[$k]['time']);
							 }else{
								 $zuixin[$k]['fabushijian']=date("Y年m月d日 H:i",$zuixin[$k]['time']);
							 }
						 } 
					 }
				 }
				 //时间格式转换结束

				 if($zuixin[$k]['jiajing']=="1"){
					 $zuixin[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
				 }else{
					 $zuixin[$k]['jingpinbiaozhi']="";
				 }
				 if($zuixin[$k]['tuijian']=="1"){
					 $zuixin[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
				 }else{
					 $zuixin[$k]['tuijianbiaozhi']="";
				 }
			 }	
			
		}else{
		 import("@.ORG.Page");
		 	$count3	= M('weibo')->where("zhuanfazhe=0 and $nowtime-time<60*60*24 and pindao=$pindaoid")->count();
			$Page3	= New Page($count3,12);
			$show3	= $Page3->show();
			
			
			$zuixin = M('weibo')->where("zhuanfazhe=0 and $nowtime-time<60*60*24 and pindao=$pindaoid")->order('time desc')->limit($Page3->firstRow.','.$Page3->listRows)->select();
	         foreach($zuixin as $k=>$v){
				foreach($zuixin[$k] as $ks=>$vs){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$zuixin[$k][$ks]=stripslashes($vs); 
					} 
				}
					$zuixin[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
						foreach($zuixin[$k]['pinglun'] as $kk=>$vv){
							$fasongzhe=M('user')->find($vv['fasongzhe']);
							$zuixin[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
							$zuixin[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
							$zuixin[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
							foreach($zuixin[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
								$nicheng=M('user')->find($vvv['fasongzhe']);
								$zuixin[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
								$zuixin[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
							}
						}
				 $pindaotupian=M('pindao')->find($v['pindao']);
				 $zuixin[$k]['pindao_tupian']=$pindaotupian['tupian'];
				 $zuozhe=M('user')->find($v['zuozhe']);
				 $zuixin[$k]['user_name']=$zuozhe['nicheng'];
				 $zuixin[$k]['user_touxiang']=$zuozhe['touxiang'];
				 $zuixin[$k]['user_id']=$zuozhe['id'];
				 //时间格式转换开始			 
				 if(date("YmdHi",$zuixin[$k]['time'])==date("YmdHi",time())){
				 	 $zuixin[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$zuixin[$k]['time'])."秒前";	 
				 }else{
					 if(date("YmdH",$zuixin[$k]['time'])==date("YmdH",time())){
						 $zuixin[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$zuixin[$k]['time'])."分钟前"; 
					 }else{
					  	 if(date("Ymd",$zuixin[$k]['time'])==date("Ymd",time())){
							 $zuixin[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$zuixin[$k]['time'])."小时前"; 
						 }else{
							 if(date("Y",$zuixin[$k]['time'])==date("Y",time())){
						 		 $zuixin[$k]['fabushijian']=date("m月d日 H:i",$zuixin[$k]['time']);
							 }else{
								 $zuixin[$k]['fabushijian']=date("Y年m月d日 H:i",$zuixin[$k]['time']);
							 }
						 } 
					 }
				 }
				 //时间格式转换结束

				 if($zuixin[$k]['jiajing']=="1"){
					 $zuixin[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
				 }else{
					 $zuixin[$k]['jingpinbiaozhi']="";
				 }
				 if($zuixin[$k]['tuijian']=="1"){
					 $zuixin[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
				 }else{
					 $zuixin[$k]['tuijianbiaozhi']="";
				 }
			 }
		}	 
		 $this->assign('zuixin',$zuixin);
		 $this->assign('page3',$show3);		 
		 
		 $this->display();
	
	}
	function changweibo(){
		
		$this->display();	
	} 
	function dochangweibo(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['time']=time();
		$_POST['zuozhe']=$_SESSION['user_id'];

		if(!empty($_POST['content']) && !empty($_POST['biaoti'])){
			
			if($_SESSION['user_id']==""){
				$this->error("请登录");	
			}else{
				//获取文字长度，根据宽度680，自动换行。
				$string=$_POST['content'];
				$_string=''; 
				$__string=''; 
				 
//				for($i=0;$i<mb_strlen($string);$i++) 
//				{ 
//					$box=imagettfbbox(14,0, 'data/STKAITI.TTF',$_string); 
//					$_string_length=$box[2]-$box[0]; 
//					$box=imagettfbbox(14,0, 'data/STKAITI.TTF',mb_substr($string,$i,1)); 
//					 
//					if( $_string_length+$box[2]-$box[0]<680) 
//					{ 
//						$_string.=mb_substr($string,$i,1); 
//					} 
//					else 
//					{ 
//						$__string.=$_string."\n"; 
//						$_string=mb_substr($string,$i,1); 
//					} 
//				} 
//				$__string.=$_string;
//以上方法，因为反应速度太慢而放弃（但优点是处理好的文字右侧边缘较齐整）。								
				while ($string) {
					if (strlen($string)>35) {
						mb_internal_encoding("UTF-8");//字符统一编码：UTF-8
						$__string.="\n".mb_substr($string,0,36);//取出一行的长度，添加到结果
						$string=mb_substr($string,36);//删除前面一行的内容
					}else{
						$__string.="\n".$string;
						$string='';
					}
				}
				//判断插入的顶图
				if($_POST['tupian']){
					$tupiangao=400;	
				}else{
					$tupiangao=0;
				}
				//确定文字范围，以便确定图片高度
				$wenzifanwei = imagettfbbox(14, 0, 'data/STKAITI.TTF', $__string);
				$wenzigao = $wenzifanwei['3']-$wenzifanwei['5'];
				//imagettfbbox() 返回一个含有 8 个单元的数组表示了文本外框的四个角：
				//0	左下角 X 位置
				//1	坐下角 Y 位置
				//2	右下角 X 位置
				//3	右下角 Y 位置
				//4	右上角 X 位置
				//5	右上角 Y 位置
				//6	左上角 X 位置
				//7	左上角 Y 位置																		
				$imWidth = 720;
				$imHeight = 200+$wenzigao+$tupiangao;
				$im = imagecreate($imWidth, $imHeight);//图片宽高
				$imlogo = imagecreatefromjpeg('Public/Share/img/logo.jpg');
				imagecolorallocate($im, 255, 255, 255);
				$heiSe = imagecolorallocate($im, 0, 0, 0);
				$baiSe = imagecolorallocate($im, 255, 255, 255);
				$randColor = imagecolorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
				/*以下几项为图片边框，边框的宽度要占用 1px 像素*/
				imageline($im, 0, 0, $imWidth, 0, $heiSe);
				imageline($im, $imWidth - 1, 1000, $imWidth - 1, $imHeight, $heiSe);
				imageline($im, 1000, $imHeight - 1, $imWidth, $imHeight - 1, $heiSe);
				imageline($im, 1000, 1000, 1000, $imHeight, $heiSe);
				$strColor = imagecolorallocate($im, 0, 0, 0);
				//加入content文字
				imagettftext($im, 14, 0, 10, 110+$tupiangao, $strColor, 'data/STKAITI.TTF', $__string);
				/*画一条虚线*/
				$lineStyle = array($heiSe, $baiSe);
				imagesetstyle($im, $lineStyle);
				imageline($im, 10, 50, $imWidth - 10, 50, IMG_COLOR_STYLED);
				//加入标题和头部注解“此图由乐嘻游长微博工具生成”
				imagettftext($im, 12, 0, 10, 30, $strColor, 'data/STKAITI.TTF', '此图由乐嘻游长微博工具生成');
				imagettftext($im, 16, 0, 10, 80, $strColor, 'data/STKAITI.TTF', '标题：'.$_POST['biaoti']);
				//生成初始的长微博图片
				$imName ='data/changweibo/chushi/'.date('YmdHis').rand(1000, 9999).'.jpg';
				imagejpeg($im, $imName);
				$imNamebeijing = imagecreatefromjpeg($imName);
				//在初始的长微博图片上加logo图片水印
				imagecopy($imNamebeijing, $imlogo, 530, $imHeight-80, 0, 0, 167, 70);
				$imNames ='data/changweibo/'.date('YmdHis').rand(1000, 9999).'s.jpg';
				//生成加了logo水印的长微博图片
				imagejpeg($imNamebeijing, $imNames);
				if($_POST['tupian']){
					//加入插入的顶图
					$imNamewanquan = imagecreatefromjpeg($imNames);
					$dingtuaa = $_POST['tupian'];
					//因为imagecreatefromjpeg函数的取名规则，'data/...',所以需要取消$_post['tupian']中的不需要的字符
					$dingtuaa = mb_substr($dingtuaa,1,100);//从$dingtuaa的第2个字符开始，取100个以内的字符,如本地lexiyoo，从第10个字符开始取
					$imdingtu = imagecreatefromjpeg($dingtuaa);
					list($widthdingtu, $heightdingtu) = getimagesize($dingtuaa);
					imagecopyresized($imNamewanquan, $imdingtu, 10, 110, 0, 0, 700, 400, $widthdingtu, $heightdingtu);
					$imNamess ='data/changweibo/'.date('YmdHis').rand(1000, 9999).'ss.jpg';
					//生成加了顶图的长微博图片
					imagejpeg($imNamewanquan, $imNamess);
					$_POST['changweibo']=$imNamess;
				}else{
					$_POST['changweibo']=$imNames;
				}
				$_POST['content']="长微博:《".$_POST['biaoti']."》".$_POST['content'];
				  if( M('weibo')->add($_POST) ){
						$useryuan=M('user')->find($_SESSION['user_id']);  
						$user['id']=$_SESSION['user_id'];
						$user['jifen']=$useryuan['jifen']+1;
						M('user')->save($user);
						if($_POST['tupian']){
							echo '<img src="'.$imNamess.'">';
						}else{
							echo '<img src="'.$imNames.'">';
						}
						
				  }else{
						$this->error('长微博发布失败！');
				  }
		    }
		
		}else{
			$this->error("请填写内容和标题");
		}
		
		
	}
	 
	function grwbsy(){
		
		//用户信息
		$id=$_SESSION["user_id"];
		$benren = M('user')->find($id);
		$benren['weiboshu']=M('weibo')->where("zuozhe=$id")->count();
		$benren['haoyoushu']=M('haoyou')->where("zhu_id=$id")->count();
		$fangkeliangzz=M('fangke')->where("bei_id=$id")->count();
		$benren['fangkeliang']=$benren['fangkeliang']+$fangkeliangzz;

		$this->assign('benren',$benren);
		//达人推荐
		$darentuijian = M('user')->where("getuijian=1")->order('gtime desc')->limit('0,8')->select();
		$this->assign('darentuijian',$darentuijian);
		//新用户推荐
		$xinyonghutuijian = M('user')->order('ctime desc')->limit('0,8')->select();
		$this->assign('xinyonghutuijian',$xinyonghutuijian);
		 
		//访客首页左下广告位
		$fksyzxggw = M('guanggaowei')->find(31);
		$this->assign('fksyzxggw',$fksyzxggw);
		//访客首页广告轮播
		$fksygglb1 = M('guanggaowei')->find(26);
		$this->assign('fksygglb1',$fksygglb1);
		$fksygglb2 = M('guanggaowei')->find(27);
		$this->assign('fksygglb2',$fksygglb2);
		$fksygglb3 = M('guanggaowei')->find(28);
		$this->assign('fksygglb3',$fksygglb3);
		$fksygglb4 = M('guanggaowei')->find(29);
		$this->assign('fksygglb4',$fksygglb4);
		$fksygglb5 = M('guanggaowei')->find(30);
		$this->assign('fksygglb5',$fksygglb5);
		
		$haoyou = 	M('haoyou')->where("zhu_id=$id")->select();
		foreach($haoyou as $k=>$v){
		$haoyouss[$k]=$haoyou[$k]['bei_id'];
		}
		$pingbi = M('pingbi')->where("zhu_id=$id")->select();
		foreach($pingbi as $k=>$v){
		$pingbiss[$k]=$pingbi[$k]['bei_id'];
		}
		$pingbisss=implode(",",$pingbiss);

		$haoyousss=implode(",",$haoyouss);
		if($pingbisss==""){
			 import("@.ORG.Page");
				$count	= M('weibo')->where("zuozhe IN ($haoyousss)")->count();
				$Page	= New Page($count,12);
				$show	= $Page->show();
				
				
				$list = M('weibo')->where("zuozhe IN ($haoyousss)")->order('time desc')->limit($Page->firstRow.','.$Page->listRows)->select();
				 foreach($list as $k=>$v){
					foreach($list[$k] as $ks=>$vs){
						if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
						$list[$k][$ks]=stripslashes($vs); 
						} 
					}
	
						$list[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
							foreach($list[$k]['pinglun'] as $kk=>$vv){
								$fasongzhe=M('user')->find($vv['fasongzhe']);
								$list[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
								$list[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
								$list[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
								foreach($list[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
									$nicheng=M('user')->find($vvv['fasongzhe']);
									$list[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
									$list[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
								}
								
							}
					 //时间格式转换开始			 
					 if(date("YmdHi",$list[$k]['time'])==date("YmdHi",time())){
						 $list[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$list[$k]['time'])."秒前";	 
					 }else{
						 if(date("YmdH",$list[$k]['time'])==date("YmdH",time())){
							 $list[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$list[$k]['time'])."分钟前"; 
						 }else{
							 if(date("Ymd",$list[$k]['time'])==date("Ymd",time())){
								 $list[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$list[$k]['time'])."小时前"; 
							 }else{
								 if(date("Y",$list[$k]['time'])==date("Y",time())){
									 $list[$k]['fabushijian']=date("m月d日 H:i",$list[$k]['time']);
								 }else{
									 $list[$k]['fabushijian']=date("Y年m月d日 H:i",$list[$k]['time']);
								 }
							 } 
						 }
					 }
					 //时间格式转换结束
	
				 
					 $zuozhe=M('user')->find($v['zuozhe']);
					 $list[$k]['user_name']=$zuozhe['nicheng'];
					 $list[$k]['user_touxiang']=$zuozhe['touxiang'];
					 
					 $pindao=M('pindao')->find($v['pindao']);
					 $list[$k]['pindao_tupian']=$pindao['tupian'];
					 if($list[$k]['jiajing']=="1"){
						 $list[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
					 }else{
						 $list[$k]['jingpinbiaozhi']="";
					 }
					 if($list[$k]['tuijian']=="1"){
						 $list[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
					 }else{
						 $list[$k]['tuijianbiaozhi']="";
					 }
					 if($list[$k]['zhuanfazhe']>"0"){
						 $yuanweibo=M('weibo')->find($v['suoshuweibo_id']);
						 $list[$k]['zhuanfa_content']=$yuanweibo['content'];
						 $list[$k]['zhuanfa_tupian1']=$yuanweibo['tupian1'];
						 $list[$k]['zhuanfa_tupian2']=$yuanweibo['tupian2'];
						 $list[$k]['zhuanfa_tupian3']=$yuanweibo['tupian3'];
						 $list[$k]['zhuanfa_tupian4']=$yuanweibo['tupian4'];
						 $list[$k]['zhuanfa_tupian5']=$yuanweibo['tupian5'];
						 $list[$k]['zhuanfa_tupian6']=$yuanweibo['tupian6'];
						 $list[$k]['zhuanfa_shipin']=$yuanweibo['shipin'];
						 $list[$k]['zhuanfa_changweibo']=$yuanweibo['changweibo'];
						 $yuanzuozhe=M('user')->find($v['suoshuzuozhe_id']);
						 $list[$k]['zhuanfa_yuanzuozhe_nicheng']=$yuanzuozhe['nicheng'];
						 $list[$k]['zhuanfa_yuanzuozhe_touxiang']=$yuanzuozhe['touxiang'];
					 }
				 }
		}else{
			 import("@.ORG.Page");
				$count	= M('weibo')->where("zuozhe IN ($haoyousss) and zuozhe NOT IN ($pingbisss)")->count();
				$Page	= New Page($count,12);
				$show	= $Page->show();
				
				
				$list = M('weibo')->where("zuozhe IN ($haoyousss) and zuozhe NOT IN ($pingbisss)")->order('time desc')->limit($Page->firstRow.','.$Page->listRows)->select();
				 foreach($list as $k=>$v){
					foreach($list[$k] as $ks=>$vs){
						if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
						$list[$k][$ks]=stripslashes($vs); 
						} 
					}
	
						$list[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
							foreach($list[$k]['pinglun'] as $kk=>$vv){
								$fasongzhe=M('user')->find($vv['fasongzhe']);
								$list[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
								$list[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
								$list[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
								foreach($list[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
									$nicheng=M('user')->find($vvv['fasongzhe']);
									$list[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
									$list[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
								}
								
							}
					 //时间格式转换开始			 
					 if(date("YmdHi",$list[$k]['time'])==date("YmdHi",time())){
						 $list[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$list[$k]['time'])."秒前";	 
					 }else{
						 if(date("YmdH",$list[$k]['time'])==date("YmdH",time())){
							 $list[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$list[$k]['time'])."分钟前"; 
						 }else{
							 if(date("Ymd",$list[$k]['time'])==date("Ymd",time())){
								 $list[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$list[$k]['time'])."小时前"; 
							 }else{
								 if(date("Y",$list[$k]['time'])==date("Y",time())){
									 $list[$k]['fabushijian']=date("m月d日 H:i",$list[$k]['time']);
								 }else{
									 $list[$k]['fabushijian']=date("Y年m月d日 H:i",$list[$k]['time']);
								 }
							 } 
						 }
					 }
					 //时间格式转换结束
	
				 
					 $zuozhe=M('user')->find($v['zuozhe']);
					 $list[$k]['user_name']=$zuozhe['nicheng'];
					 $list[$k]['user_touxiang']=$zuozhe['touxiang'];
					 
					 $pindao=M('pindao')->find($v['pindao']);
					 $list[$k]['pindao_tupian']=$pindao['tupian'];
					 
					 if($list[$k]['zhuanfazhe']>"0"){
						 $yuanweibo=M('weibo')->find($v['suoshuweibo_id']);
						 $list[$k]['zhuanfa_content']=$yuanweibo['content'];
						 $list[$k]['zhuanfa_tupian1']=$yuanweibo['tupian1'];
						 $list[$k]['zhuanfa_tupian2']=$yuanweibo['tupian2'];
						 $list[$k]['zhuanfa_tupian3']=$yuanweibo['tupian3'];
						 $list[$k]['zhuanfa_tupian4']=$yuanweibo['tupian4'];
						 $list[$k]['zhuanfa_tupian5']=$yuanweibo['tupian5'];
						 $list[$k]['zhuanfa_tupian6']=$yuanweibo['tupian6'];
						 $list[$k]['zhuanfa_shipin']=$yuanweibo['shipin'];
						 $list[$k]['zhuanfa_changweibo']=$yuanweibo['changweibo'];
						 $yuanzuozhe=M('user')->find($v['suoshuzuozhe_id']);
						 $list[$k]['zhuanfa_yuanzuozhe_nicheng']=$yuanzuozhe['nicheng'];
						 $list[$k]['zhuanfa_yuanzuozhe_touxiang']=$yuanzuozhe['touxiang'];
					 }
					 if($list[$k]['jiajing']=="1"){
						 $list[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
					 }else{
						 $list[$k]['jingpinbiaozhi']="";
					 }
					 if($list[$k]['tuijian']=="1"){
						 $list[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
					 }else{
						 $list[$k]['tuijianbiaozhi']="";
					 }
				 }
	
		}
		 $this->assign('list',$list);
		 $this->assign('page',$show);
			$biaoqingtupian=M('biaoqing')->order('xu asc,id desc')->select();
			$this->assign('biaoqingtupian',$biaoqingtupian);
		
		
		$this->display();	 
	}
	function biaoqing_wenbenkuang(){
		$c_id=$_REQUEST["cid"];
		$biaoqing=M('biaoqing')->find($c_id);
		$qwe="<img src=\"".$biaoqing['tupian']."\" />";
		echo json_encode($qwe);

	}
	//个人微博首页发小喇叭
	function doxiaolaba(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['time']=time();
		$_POST['zuozhe']=$_SESSION['user_id'];		
		if($_POST['zuozhe']=='' || $_POST['content']==''){
			$this->error("信息不完整");	
		}
		$xiaolabashu=M('user')->find($_POST['zuozhe']);
		if($xiaolabashu['xiaolabashu']<1){
			$this->error('亲，小喇叭不足1个');
		}else{
			if( M('xiaolaba')->add($_POST) ){
				$xiaolabashujian['id']=$_POST['zuozhe'];
				$xiaolabashujian['xiaolabashu']=$xiaolabashu['xiaolabashu']-1;
				M('user')->save($xiaolabashujian);
				$this->success('小喇叭发布成功！');
			}else{
				$this->error('小喇叭发布失败！');
			}
		}
	}
	//个人微博首页阅读数加
	function yuedushujia(){
		$useryuan=M('user')->find($_SESSION['user_id']);
		if($_SESSION['user_id']!="" && $useryuan['yueducishu']>=1){
			$weiboid=$_POST["cid"];
			$yuedushu=M('weibo')->find($weiboid);
			$cc=$yuedushu['yuedushu']+1;
			$_POST['yuedushu']=$cc;
			$_POST['id']=$weiboid;
			M('weibo')->save($_POST);
					
			$user['id']=$_SESSION['user_id'];
			$user['yueducishu']=$useryuan['yueducishu']-1;
			$user['jifen']=$useryuan['jifen']+1;
			M('user')->save($user);		
			echo $cc;exit;
		}else{
			$weiboid=$_POST["cid"];
			$yuedushu=M('weibo')->find($weiboid);
			$cc=$yuedushu['yuedushu'];	
			echo $cc;exit;	
		}
	}
	//个人微博首页赞数加
	function zanshujia(){
		$useryuan=M('user')->find($_SESSION['user_id']);
		if($_SESSION['user_id']!="" && $useryuan['zancishu']>=1){
			$weiboid=$_POST["cid"];
			$zanshu=M('weibo')->find($weiboid);
			$cc=$zanshu['zanshu']+1;
			$_POST['zanshu']=$cc;
			$_POST['id']=$weiboid;
			M('weibo')->save($_POST);
			$user['id']=$_SESSION['user_id'];
			$user['zancishu']=$useryuan['zancishu']-1;
			$user['jifen']=$useryuan['jifen']+1;
			M('user')->save($user);
			echo $cc;exit;
		}else{
			$weiboid=$_POST["cid"];
			$zanshu=M('weibo')->find($weiboid);
			$cc=$zanshu['zanshu'];	
			echo $cc;exit;	
		}
	}
	//个人微博首页踩数加
	function caishujia(){
		$useryuan=M('user')->find($_SESSION['user_id']);
		if($_SESSION['user_id']!="" && $useryuan['caicishu']>=1){
			$weiboid=$_POST["cid"];
			$caishu=M('weibo')->find($weiboid);
			$cc=$caishu['caishu']+1;
			$_POST['caishu']=$cc;
			$_POST['id']=$weiboid;
			M('weibo')->save($_POST);
			$user['id']=$_SESSION['user_id'];
			$user['caicishu']=$useryuan['caicishu']-1;
			$user['jifen']=$useryuan['jifen']+1;
			M('user')->save($user);
			echo $cc;exit;
		}else{
			$weiboid=$_POST["cid"];
			$caishu=M('weibo')->find($weiboid);
			$cc=$caishu['caishu'];	
			echo $cc;exit;	
		}
	}
	
	//发微博
	function doweibo(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['time']=time();
		$_POST['zuozhe']=$_SESSION['user_id'];
		$_POST['yuedushu']="0";
		$_POST['zanshu']="0";
		$_POST['caishu']="0";
		$_POST['tuijian']="0";
		$_POST['jiajing']="0";
		$_POST['wenzilian']="0";
				
		if($_POST['content']=='' && $_POST['tupian1']=='' && $_POST['shipin']==''){
			$this->error("请添加微博内容");	
		}
		      if( M('weibo')->add($_POST) ){
					$useryuan=M('user')->find($_SESSION['user_id']);  
					$user['id']=$_SESSION['user_id'];
					$user['jifen']=$useryuan['jifen']+1;
					M('user')->save($user);
					$this->success('微博发布成功！');
			  }else{
					$this->error('微博发布失败！');
			  }
	    
	}
	
	function grwb(){
		
		$id=$_SESSION['user_id'];
		
		$fangke = M('fangke')->where("bei_id=$id")->order('time desc')->limit('0,8')->select();
		foreach($fangke as $k=>$v){
			$fangkexinxi=M('user')->find($v['zhu_id']);
			$fangke[$k]['fangke_touxiang']=$fangkexinxi['touxiang'];	
			$fangke[$k]['fangke_nicheng']=$fangkexinxi['nicheng'];	
		}
		$this->assign('fangke',$fangke);
		
		//用户信息		
		$benren = M('user')->find($id);
		$benren['weiboshu']=M('weibo')->where("zuozhe=$id")->count();
		$benren['haoyoushu']=M('haoyou')->where("zhu_id=$id")->count();
		$fangkeliangzz=M('fangke')->where("bei_id=$id")->count();
		$benren['fangkeliang']=$benren['fangkeliang']+$fangkeliangzz;
		$this->assign('benren',$benren);
		
		$haoyou = 	M('haoyou')->where("zhu_id=$id")->select();
		foreach($haoyou as $k=>$v){
		$haoyouss[$k]=$haoyou[$k]['bei_id'];
		}
		$haoyousss=implode(",",$haoyouss);

		$pingbi = M('pingbi')->where("zhu_id=$id")->select();
		foreach($pingbi as $k=>$v){
		$pingbiss[$k]=$pingbi[$k]['bei_id'];
		}
		$pingbisss=implode(",",$pingbiss);
		if($pingbisss==""){
			//频道列表
			$pindao = M('pindao')->order('id asc')->select();
			foreach($pindao as $k => $v){
				$pindao[$k]['weiboshu'] = M('weibo')->where("zuozhe IN ($haoyousss) and pindao=$v[id]")->count();
			}
			$this->assign('pindao',$pindao);
			
			//访客首页左下广告位
			$fksyzxggw = M('guanggaowei')->find(31);
			$this->assign('fksyzxggw',$fksyzxggw);
	
			//微博列表
			$pindaoid=$_GET["pindaoid"];
			if($pindaoid==""){
			 import("@.ORG.Page");
				$count	= M('weibo')->where("zuozhe IN ($haoyousss)")->count();
				$Page	= New Page($count,12);
				$show	= $Page->show();
				
				
				$list = M('weibo')->where("zuozhe IN ($haoyousss)")->order('time desc')->limit($Page->firstRow.','.$Page->listRows)->select();
				 foreach($list as $k=>$v){
					foreach($list[$k] as $ks=>$vs){
						if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
						$list[$k][$ks]=stripslashes($vs); 
						} 
					}
	
						$list[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
							foreach($list[$k]['pinglun'] as $kk=>$vv){
								$fasongzhe=M('user')->find($vv['fasongzhe']);
								$list[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
								$list[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
								$list[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
								foreach($list[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
									$nicheng=M('user')->find($vvv['fasongzhe']);
									$list[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
									$list[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
								}
							}
	
	
					 $zuozhe=M('user')->find($v['zuozhe']);
					 $list[$k]['user_name']=$zuozhe['nicheng'];
					 $list[$k]['user_touxiang']=$zuozhe['touxiang'];
					 
					 $pindao=M('pindao')->find($v['pindao']);
					 $list[$k]['pindao_tupian']=$pindao['tupian'];
					 //时间格式转换开始			 
					 if(date("YmdHi",$list[$k]['time'])==date("YmdHi",time())){
						 $list[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$list[$k]['time'])."秒前";	 
					 }else{
						 if(date("YmdH",$list[$k]['time'])==date("YmdH",time())){
							 $list[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$list[$k]['time'])."分钟前"; 
						 }else{
							 if(date("Ymd",$list[$k]['time'])==date("Ymd",time())){
								 $list[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$list[$k]['time'])."小时前"; 
							 }else{
								 if(date("Y",$list[$k]['time'])==date("Y",time())){
									 $list[$k]['fabushijian']=date("m月d日 H:i",$list[$k]['time']);
								 }else{
									 $list[$k]['fabushijian']=date("Y年m月d日 H:i",$list[$k]['time']);
								 }
							 } 
						 }
					 }
					 //时间格式转换结束
					 if($list[$k]['zhuanfazhe']>"0"){
						 $yuanweibo=M('weibo')->find($v['suoshuweibo_id']);
						 $list[$k]['zhuanfa_content']=$yuanweibo['content'];
						 $list[$k]['zhuanfa_tupian1']=$yuanweibo['tupian1'];
						 $list[$k]['zhuanfa_tupian2']=$yuanweibo['tupian2'];
						 $list[$k]['zhuanfa_tupian3']=$yuanweibo['tupian3'];
						 $list[$k]['zhuanfa_tupian4']=$yuanweibo['tupian4'];
						 $list[$k]['zhuanfa_tupian5']=$yuanweibo['tupian5'];
						 $list[$k]['zhuanfa_tupian6']=$yuanweibo['tupian6'];
						 $list[$k]['zhuanfa_shipin']=$yuanweibo['shipin'];
						 $list[$k]['zhuanfa_changweibo']=$yuanweibo['changweibo'];
						 $yuanzuozhe=M('user')->find($v['suoshuzuozhe_id']);
						 $list[$k]['zhuanfa_yuanzuozhe_nicheng']=$yuanzuozhe['nicheng'];
						 $list[$k]['zhuanfa_yuanzuozhe_touxiang']=$yuanzuozhe['touxiang'];
					 }
					 if($list[$k]['jiajing']=="1"){
						 $list[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
					 }else{
						 $list[$k]['jingpinbiaozhi']="";
					 }
					 if($list[$k]['tuijian']=="1"){
						 $list[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
					 }else{
						 $list[$k]['tuijianbiaozhi']="";
					 }
				 }	
				
			}else{
			 import("@.ORG.Page");
				$count	= M('weibo')->where("zuozhe IN ($haoyousss) and pindao=$pindaoid")->count();
				$Page	= New Page($count,12);
				$show	= $Page->show();
				
				
				$list = M('weibo')->where("zuozhe IN ($haoyousss) and pindao=$pindaoid")->order('time asc')->limit($Page->firstRow.','.$Page->listRows)->select();
				 foreach($list as $k=>$v){
					foreach($list[$k] as $ks=>$vs){
						if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
						$list[$k][$ks]=stripslashes($vs); 
						} 
					}
	
						$list[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
							foreach($list[$k]['pinglun'] as $kk=>$vv){
								$fasongzhe=M('user')->find($vv['fasongzhe']);
								$list[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
								$list[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
								$list[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
								foreach($list[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
									$nicheng=M('user')->find($vvv['fasongzhe']);
									$list[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
									$list[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
								}
							}
	
	 
					 $zuozhe=M('user')->find($v['zuozhe']);
					 $list[$k]['user_name']=$zuozhe['nicheng'];
					 $list[$k]['user_touxiang']=$zuozhe['touxiang'];
					 
					 $pindao=M('pindao')->find($v['pindao']);
					 $list[$k]['pindao_tupian']=$pindao['tupian'];
					 //时间格式转换开始			 
					 if(date("YmdHi",$list[$k]['time'])==date("YmdHi",time())){
						 $list[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$list[$k]['time'])."秒前";	 
					 }else{
						 if(date("YmdH",$list[$k]['time'])==date("YmdH",time())){
							 $list[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$list[$k]['time'])."分钟前"; 
						 }else{
							 if(date("Ymd",$list[$k]['time'])==date("Ymd",time())){
								 $list[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$list[$k]['time'])."小时前"; 
							 }else{
								 if(date("Y",$list[$k]['time'])==date("Y",time())){
									 $list[$k]['fabushijian']=date("m月d日 H:i",$list[$k]['time']);
								 }else{
									 $list[$k]['fabushijian']=date("Y年m月d日 H:i",$list[$k]['time']);
								 }
							 } 
						 }
					 }
					 //时间格式转换结束
					 if($list[$k]['zhuanfazhe']>"0"){
						 $yuanweibo=M('weibo')->find($v['suoshuweibo_id']);
						 $list[$k]['zhuanfa_content']=$yuanweibo['content'];
						 $list[$k]['zhuanfa_tupian1']=$yuanweibo['tupian1'];
						 $list[$k]['zhuanfa_tupian2']=$yuanweibo['tupian2'];
						 $list[$k]['zhuanfa_tupian3']=$yuanweibo['tupian3'];
						 $list[$k]['zhuanfa_tupian4']=$yuanweibo['tupian4'];
						 $list[$k]['zhuanfa_tupian5']=$yuanweibo['tupian5'];
						 $list[$k]['zhuanfa_tupian6']=$yuanweibo['tupian6'];
						 $list[$k]['zhuanfa_shipin']=$yuanweibo['shipin'];
						 $list[$k]['zhuanfa_changweibo']=$yuanweibo['changweibo'];
						 $yuanzuozhe=M('user')->find($v['suoshuzuozhe_id']);
						 $list[$k]['zhuanfa_yuanzuozhe_nicheng']=$yuanzuozhe['nicheng'];
						 $list[$k]['zhuanfa_yuanzuozhe_touxiang']=$yuanzuozhe['touxiang'];
					 }
					 if($list[$k]['jiajing']=="1"){
						 $list[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
					 }else{
						 $list[$k]['jingpinbiaozhi']="";
					 }
					 if($list[$k]['tuijian']=="1"){
						 $list[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
					 }else{
						 $list[$k]['tuijianbiaozhi']="";
					 }
				 }
			}
		}else{
			//频道列表
			$pindao = M('pindao')->order('id asc')->select();
			foreach($pindao as $k => $v){
				$pindao[$k]['weiboshu'] = M('weibo')->where("zuozhe IN ($haoyousss) and zuozhe NOT IN ($pingbisss) and pindao=$v[id]")->count();
			}
			$this->assign('pindao',$pindao);
			
			//访客首页左下广告位
			$fksyzxggw = M('guanggaowei')->find(31);
			$this->assign('fksyzxggw',$fksyzxggw);
	
			//微博列表
			$pindaoid=$_GET["pindaoid"];
			if($pindaoid==""){
			 import("@.ORG.Page");
				$count	= M('weibo')->where("zuozhe IN ($haoyousss) and zuozhe NOT IN ($pingbisss)")->count();
				$Page	= New Page($count,12);
				$show	= $Page->show();
				
				
				$list = M('weibo')->where("zuozhe IN ($haoyousss) and zuozhe NOT IN ($pingbisss)")->order('time desc')->limit($Page->firstRow.','.$Page->listRows)->select();
				 foreach($list as $k=>$v){
					foreach($list[$k] as $ks=>$vs){
						if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
						$list[$k][$ks]=stripslashes($vs); 
						} 
					}
	
						$list[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
							foreach($list[$k]['pinglun'] as $kk=>$vv){
								$fasongzhe=M('user')->find($vv['fasongzhe']);
								$list[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
								$list[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
								$list[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
								foreach($list[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
									$nicheng=M('user')->find($vvv['fasongzhe']);
									$list[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
									$list[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
								}
							}
	
	
					 $zuozhe=M('user')->find($v['zuozhe']);
					 $list[$k]['user_name']=$zuozhe['nicheng'];
					 $list[$k]['user_touxiang']=$zuozhe['touxiang'];
					 
					 $pindao=M('pindao')->find($v['pindao']);
					 $list[$k]['pindao_tupian']=$pindao['tupian'];
					 //时间格式转换开始			 
					 if(date("YmdHi",$list[$k]['time'])==date("YmdHi",time())){
						 $list[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$list[$k]['time'])."秒前";	 
					 }else{
						 if(date("YmdH",$list[$k]['time'])==date("YmdH",time())){
							 $list[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$list[$k]['time'])."分钟前"; 
						 }else{
							 if(date("Ymd",$list[$k]['time'])==date("Ymd",time())){
								 $list[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$list[$k]['time'])."小时前"; 
							 }else{
								 if(date("Y",$list[$k]['time'])==date("Y",time())){
									 $list[$k]['fabushijian']=date("m月d日 H:i",$list[$k]['time']);
								 }else{
									 $list[$k]['fabushijian']=date("Y年m月d日 H:i",$list[$k]['time']);
								 }
							 } 
						 }
					 }
					 //时间格式转换结束
					 if($list[$k]['zhuanfazhe']>"0"){
						 $yuanweibo=M('weibo')->find($v['suoshuweibo_id']);
						 $list[$k]['zhuanfa_content']=$yuanweibo['content'];
						 $list[$k]['zhuanfa_tupian1']=$yuanweibo['tupian1'];
						 $list[$k]['zhuanfa_tupian2']=$yuanweibo['tupian2'];
						 $list[$k]['zhuanfa_tupian3']=$yuanweibo['tupian3'];
						 $list[$k]['zhuanfa_tupian4']=$yuanweibo['tupian4'];
						 $list[$k]['zhuanfa_tupian5']=$yuanweibo['tupian5'];
						 $list[$k]['zhuanfa_tupian6']=$yuanweibo['tupian6'];
						 $list[$k]['zhuanfa_shipin']=$yuanweibo['shipin'];
						 $list[$k]['zhuanfa_changweibo']=$yuanweibo['changweibo'];
						 $yuanzuozhe=M('user')->find($v['suoshuzuozhe_id']);
						 $list[$k]['zhuanfa_yuanzuozhe_nicheng']=$yuanzuozhe['nicheng'];
						 $list[$k]['zhuanfa_yuanzuozhe_touxiang']=$yuanzuozhe['touxiang'];
					 }
					 if($list[$k]['jiajing']=="1"){
						 $list[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
					 }else{
						 $list[$k]['jingpinbiaozhi']="";
					 }
					 if($list[$k]['tuijian']=="1"){
						 $list[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
					 }else{
						 $list[$k]['tuijianbiaozhi']="";
					 }
				 }	
				
			}else{
			 import("@.ORG.Page");
				$count	= M('weibo')->where("zuozhe IN ($haoyousss) and pindao=$pindaoid")->count();
				$Page	= New Page($count,12);
				$show	= $Page->show();
				
				
				$list = M('weibo')->where("zuozhe IN ($haoyousss) and pindao=$pindaoid")->order('time desc')->limit($Page->firstRow.','.$Page->listRows)->select();
				 foreach($list as $k=>$v){
					foreach($list[$k] as $ks=>$vs){
						if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
						$list[$k][$ks]=stripslashes($vs); 
						} 
					}
	
						$list[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
							foreach($list[$k]['pinglun'] as $kk=>$vv){
								$fasongzhe=M('user')->find($vv['fasongzhe']);
								$list[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
								$list[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
								$list[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
								foreach($list[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
									$nicheng=M('user')->find($vvv['fasongzhe']);
									$list[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
									$list[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
								}
							}
	
	 
					 $zuozhe=M('user')->find($v['zuozhe']);
					 $list[$k]['user_name']=$zuozhe['nicheng'];
					 $list[$k]['user_touxiang']=$zuozhe['touxiang'];
					 
					 $pindao=M('pindao')->find($v['pindao']);
					 $list[$k]['pindao_tupian']=$pindao['tupian'];
					 //时间格式转换开始			 
					 if(date("YmdHi",$list[$k]['time'])==date("YmdHi",time())){
						 $list[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$list[$k]['time'])."秒前";	 
					 }else{
						 if(date("YmdH",$list[$k]['time'])==date("YmdH",time())){
							 $list[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$list[$k]['time'])."分钟前"; 
						 }else{
							 if(date("Ymd",$list[$k]['time'])==date("Ymd",time())){
								 $list[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$list[$k]['time'])."小时前"; 
							 }else{
								 if(date("Y",$list[$k]['time'])==date("Y",time())){
									 $list[$k]['fabushijian']=date("m月d日 H:i",$list[$k]['time']);
								 }else{
									 $list[$k]['fabushijian']=date("Y年m月d日 H:i",$list[$k]['time']);
								 }
							 } 
						 }
					 }
					 //时间格式转换结束
					 if($list[$k]['zhuanfazhe']>"0"){
						 $yuanweibo=M('weibo')->find($v['suoshuweibo_id']);
						 $list[$k]['zhuanfa_content']=$yuanweibo['content'];
						 $list[$k]['zhuanfa_tupian1']=$yuanweibo['tupian1'];
						 $list[$k]['zhuanfa_tupian2']=$yuanweibo['tupian2'];
						 $list[$k]['zhuanfa_tupian3']=$yuanweibo['tupian3'];
						 $list[$k]['zhuanfa_tupian4']=$yuanweibo['tupian4'];
						 $list[$k]['zhuanfa_tupian5']=$yuanweibo['tupian5'];
						 $list[$k]['zhuanfa_tupian6']=$yuanweibo['tupian6'];
						 $list[$k]['zhuanfa_shipin']=$yuanweibo['shipin'];
						 $list[$k]['zhuanfa_changweibo']=$yuanweibo['changweibo'];
						 $yuanzuozhe=M('user')->find($v['suoshuzuozhe_id']);
						 $list[$k]['zhuanfa_yuanzuozhe_nicheng']=$yuanzuozhe['nicheng'];
						 $list[$k]['zhuanfa_yuanzuozhe_touxiang']=$yuanzuozhe['touxiang'];
					 }
					 if($list[$k]['jiajing']=="1"){
						 $list[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
					 }else{
						 $list[$k]['jingpinbiaozhi']="";
					 }
					 if($list[$k]['tuijian']=="1"){
						 $list[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
					 }else{
						 $list[$k]['tuijianbiaozhi']="";
					 }
				 }
			}
	
		}
			 
		 		 
		 $this->assign('list',$list);
		 $this->assign('page',$show);

		$this->display();	 
	}
	function aqzx(){
		$this->display();	 
	}
     function aqzx_do(){
		
			 $user_id=$_SESSION["user_id"];
			if($user_id==''){
			   $this->assign('jumpUrl', U('index'));
			   $this->error("请登录");  
			}
			$user=M('user')->where("id=$user_id")->find();
			$this->assign($user);
			
			$user_passy=md5($_POST['user_passy']);
			if($user_passy!=$user['user_pass']){
			     $this->error("原密码错误"); exit;
			}
			
			if($_POST["user_pass"]==''){
				$this->error("信息不完整");	exit;
			}

			
			$_POST['id']=$_SESSION["user_id"];
			$_POST['user_pass']=md5($_POST['user_pass']);

		  if( M('user')->save($_POST) ){
				$this->assign('jumpUrl', U('aqzx'));
				$this->success('修改成功！');
		  }else{
				$this->error('修改失败！');
		  }

	 }

	function cwjy(){
		$this->display();	 
	}
	function grsz(){
		$id=$_SESSION['user_id'];
		//城市查询
		$shengs = M('city')->where("city_parent_id=0")->order('city_id asc')->select();
		$this->assign('shengs',$shengs);
		//模板设置
		$pifu=M('pifu')->order('id asc')->limit('0,4')->select();
		$this->assign('pifu',$pifu);


		//用户个人信息查询
		$xinxi = M('user')->find($id);

		$this->assign($xinxi);
		$shis = M('city')->where("city_parent_id=".$xinxi["sheng"]."")->select();
		$this->assign('shis',$shis);
		//黑名单
		$heimingdan = M('heimingdan')->where("zhu_id=$id")->order('ctime desc')->select();
			foreach($heimingdan as $k=>$v){
				$heimingdanmingcheng=M('user')->find($v['bei_id']);
				$heimingdan[$k]['name']=$heimingdanmingcheng['nicheng'];
			}
		$this->assign('heimingdan',$heimingdan);
		
		$this->display(); 
	}
	function delheimingdan(){
	    $ids = $_POST['ids'];
		$del = M('heimingdan')->where("id IN ($ids)")->delete();
        echo $del?'1':'0';
	}	
	//从省到市
	function get_shi2(){
			 $shengss=$_POST['sheng'];
			
			 $shiss = M('city')->where("city_parent_id=$shengss")->select();
			 foreach($shiss as $k=>$v){
			   $asd.="<option value='$v[city_id]'>$v[city_name]</option>";
			 }
			 echo $asd;
    }

	//个人设置baocun
	function dogrsz(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}

		$_POST['id']=$_SESSION['user_id'];

		
		
		if($_POST['nicheng']==''){
			$this->error("昵称必须填写");	
		}
		      if( M('user')->save($_POST) ){
					$this->assign('jumpUrl', U('grsz'));
					$this->success('设置成功！');
			  }else{
					$this->error('设置失败！');
			  }
	    
	}
	//个人设置头像截取
	function dotouxiangjiequ(){
		$_POST['tupian']=$_POST['cid'];	
				$imNamebeijing = imagecreatefromjpeg('Public/Share/img/touxiangbeijing.jpg');
					$dingtuaa = $_POST['tupian'];
					//因为imagecreatefromjpeg函数的取名规则，'data/...',所以需要取消$_post['tupian']中的不需要的字符
					$dingtuaa = mb_substr($dingtuaa,1,100);//从$dingtuaa的第2个字符开始，取100个以内的字符,如本地lexiyoo，从第10个字符开始取
					$imdingtu = imagecreatefromjpeg($dingtuaa);
					list($widthdingtu, $heightdingtu) = getimagesize($dingtuaa);
					if($widthdingtu>190){
						$x = ($widthdingtu-190)/2;
					}else{
						$x = 0;
					}
					if($heightdingtu>190){
						$y = ($heightdingtu-190)/2;
					}else{
						$y = 0;
					}
					imagecopy($imNamebeijing, $imdingtu, 0, 0, $x, $y, 190, 190);
					$imNamess ='data/touxiang/'.date('YmdHis').rand(1000, 9999).'.jpg';
					//生成加了顶图的长微博图片
					imagejpeg($imNamebeijing, $imNamess);
//		$cac="/lexiyoo/".$imNamess;	//本地用"/lexiyoo/",服务器用"/"
		$cac="/".$imNamess;
		echo  json_encode($cac);

	    
	}
	//个人设置访客页首图截取
	function dofangkeyeshoutujiequ(){
		$_POST['tupian']=$_POST['cid'];	
				$imNamebeijing = imagecreatefromjpeg('Public/Share/img/fangkeyeshoutubeijing.jpg');
					$dingtuaa = $_POST['tupian'];
					//因为imagecreatefromjpeg函数的取名规则，'data/...',所以需要取消$_post['tupian']中的不需要的字符
					$dingtuaa = mb_substr($dingtuaa,1,100);//从$dingtuaa的第2个字符开始，取100个以内的字符,如本地lexiyoo，从第10个字符开始取
					$imdingtu = imagecreatefromjpeg($dingtuaa);
					list($widthdingtu, $heightdingtu) = getimagesize($dingtuaa);
					if($widthdingtu>1004){
						$x = ($widthdingtu-1004)/2;
					}else{
						$x = 0;
					}
					if($heightdingtu>268){
						$y = ($heightdingtu-268)/2;
					}else{
						$y = 0;
					}
					imagecopy($imNamebeijing, $imdingtu, 0, 0, $x, $y, 1004, 268);
					$imNamess ='data/fangkeyeshoutu/'.date('YmdHis').rand(1000, 9999).'.jpg';
					//生成加了顶图的长微博图片
					imagejpeg($imNamebeijing, $imNamess);
//		$cac="/lexiyoo/".$imNamess;	//本地用"/lexiyoo/",服务器用"/"
		$cac="/".$imNamess;
		echo  json_encode($cac);

	    
	}
	//个人模板设置baocun
	function mubanshezhi(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['id']=$_SESSION['user_id'];				
		if($_POST['muban']=='0'){
			$this->error("请选择模板");	
		}
		$userxinxi=M('user')->find($_POST['id']);
		if($_POST['muban']=='5' && $userxinxi['daren']=='0' ){
			$this->error("非达人不能选择达人模板");
		}
		$muban['id']=$_POST['id'];
		$muban['muban']=$_POST['muban'];
		      if( M('user')->save($muban) ){
					$this->assign('jumpUrl', U('grsz'));
					$this->success('设置成功！');
			  }else{
					$this->error('设置失败！');
			  }
	    
	}

	//访客首页发评论
	function dopingluns(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['time']=time();
		$_POST['fasongzhe']=$_SESSION['user_id'];
		$fasong=$_POST['weibo_id'];
		$fasongid=M('weibo')->find($fasong);
		$_POST['jieshouzhe']=$fasongid['zuozhe'];
		$_POST['pinglun_id']="0";
		if($_POST['content']==''){
			$this->error("信息不完整");	
		}
		if($_SESSION['user_id']==""){
			$this->error("请登录");	
		}else{
			$zuozhepinglunshezhi=M('user')->find($fasongid['zuozhe']);
			if($zuozhepinglunshezhi['pinglunshezhi']==0){
				if( M('pinglun')->add($_POST) ){
					$useryuan=M('user')->find($_SESSION['user_id']);  
					if($useryuan['pingluncishu']>=1){
						$user['id']=$_SESSION['user_id'];
						$user['pingluncishu']=$useryuan['pingluncishu']-1;
						$user['jifen']=$useryuan['jifen']+1;
						M('user')->save($user);
					}	
				  
					$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
					$this->success('评论成功！');
				}else{
					$this->error('评论失败！');
				}	
			}else{
				if($zuozhepinglunshezhi['pinglunshezhi']==1){
					$zhurenid=$fasongid['zuozhe'];
					$pinglunzheid=$_SESSION['user_id'];
					$haoyou = M('haoyou')->where("zhu_id=$zhurenid and bei_id=$pinglunzheid")->select();
					if($haoyou){
						if( M('pinglun')->add($_POST) ){
							$useryuan=M('user')->find($_SESSION['user_id']);  
							if($useryuan['pingluncishu']>=1){
								$user['id']=$_SESSION['user_id'];
								$user['pingluncishu']=$useryuan['pingluncishu']-1;
								$user['jifen']=$useryuan['jifen']+1;
								M('user')->save($user);
							}	
						  
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->success('评论成功！');
						}else{
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->error('评论失败！');
						}
					}else{
						$this->error('主人设置仅好友可以评论');
					}
				}else{
					if($_POST['fasongzhe']==$fasongid['zuozhe']){
						if( M('pinglun')->add($_POST) ){
							$useryuan=M('user')->find($_SESSION['user_id']);  
							if($useryuan['pingluncishu']>=1){
								$user['id']=$_SESSION['user_id'];
								$user['pingluncishu']=$useryuan['pingluncishu']-1;
								$user['jifen']=$useryuan['jifen']+1;
								M('user')->save($user);
							}	
						  
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->success('评论成功！');
						}else{
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->error('评论失败！');
						}
					}else{
						$this->error('主人设置仅自己可以评论');
					}

				}
			
			}


		}
}	
	//访客首页发评论回复
	function dogrwbsypinglunhuifus(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['time']=time();
		$_POST['fasongzhe']=$_SESSION['user_id'];
		$fasong=$_POST['pinglun_id'];
		$fasongid=M('pinglun')->find($fasong);
		$_POST['jieshouzhe']=$fasongid['fasongzhe'];
		$_POST['weibo_id']=$fasongid['weibo_id'];
		if($_POST['content']==''){
			$this->error("信息不完整");	
		}
		if($_SESSION['user_id']==""){
			$this->error("请登录");	
		}else{
			$zuozhepinglunshezhi=M('user')->find($fasongid['zuozhe']);
			if($zuozhepinglunshezhi['pinglunshezhi']==0){
				if( M('pinglun')->add($_POST) ){
					$useryuan=M('user')->find($_SESSION['user_id']);  
					if($useryuan['pingluncishu']>=1){
						$user['id']=$_SESSION['user_id'];
						$user['pingluncishu']=$useryuan['pingluncishu']-1;
						$user['jifen']=$useryuan['jifen']+1;
						M('user')->save($user);
					}	
				  
					$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
					$this->success('评论成功！');
				}else{
					$this->error('评论失败！');
				}	
			}else{
				if($zuozhepinglunshezhi['pinglunshezhi']==1){
					$zhurenid=$fasongid['zuozhe'];
					$pinglunzheid=$_SESSION['user_id'];
					$haoyou = M('haoyou')->where("zhu_id=$zhurenid and bei_id=$pinglunzheid")->select();
					if($haoyou){
						if( M('pinglun')->add($_POST) ){
							$useryuan=M('user')->find($_SESSION['user_id']);  
							if($useryuan['pingluncishu']>=1){
								$user['id']=$_SESSION['user_id'];
								$user['pingluncishu']=$useryuan['pingluncishu']-1;
								$user['jifen']=$useryuan['jifen']+1;
								M('user')->save($user);
							}	
						  
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->success('评论成功！');
						}else{
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->error('评论失败！');
						}
					}else{
						$this->error('主人设置仅好友可以评论');
					}
				}else{
					if($_POST['fasongzhe']==$fasongid['zuozhe']){
						if( M('pinglun')->add($_POST) ){
							$useryuan=M('user')->find($_SESSION['user_id']);  
							if($useryuan['pingluncishu']>=1){
								$user['id']=$_SESSION['user_id'];
								$user['pingluncishu']=$useryuan['pingluncishu']-1;
								$user['jifen']=$useryuan['jifen']+1;
								M('user')->save($user);
							}	
						  
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->success('评论成功！');
						}else{
							$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
							$this->error('评论失败！');
						}
					}else{
						$this->error('主人设置仅自己可以评论');
					}

				}
			
			}


		}
}
  
	function fksy(){
		//访客记录
		$fangkeru['bei_id']=$_GET['quid'];
		$fangkeru['zhu_id']=$_SESSION['user_id'];
		$fangkeru['time']=time();
		$fangkezhu=M('user')->find($_SESSION['user_id']);
		if($fangkeru['bei_id']!=$fangkeru['zhu_id'] && $fangkezhu['hengjishezhi']==0){
			M('fangke')->add($fangkeru);
		}
		
		$_SESSION['quid']=$_GET['quid'];
		$id=$_SESSION['quid'];
		
		$fangke = M('fangke')->where("bei_id=$id")->order('time desc')->limit('0,8')->select();
		foreach($fangke as $k=>$v){
			$fangkexinxi=M('user')->find($v['zhu_id']);
			$fangke[$k]['fangke_touxiang']=$fangkexinxi['touxiang'];
			$fangke[$k]['fangke_nicheng']=$fangkexinxi['nicheng'];	
		}
		$this->assign('fangke',$fangke);
				
		//用户信息		
		$benren = M('user')->find($id);
		$benren['weiboshu']=M('weibo')->where("zuozhe=$id")->count();
		$fangkeliangzz=M('fangke')->where("bei_id=$id")->count();
		$benren['fangkeliang']=$benren['fangkeliang']+$fangkeliangzz;
		if($benren['darenpiaoshu']<"5000"){
			$benren['darenxiajipiaoshu']="5000";	
		}else{
			if($benren['darenpiaoshu']<"10000"){
				$benren['darenxiajipiaoshu']="10000";	
			}else{
				if($benren['darenpiaoshu']<"50000"){
					$benren['darenxiajipiaoshu']="50000";	
				}else{
					if($benren['darenpiaoshu']<"100000"){
						$benren['darenxiajipiaoshu']="100000";	
					}else{
						if($benren['darenpiaoshu']<"500000"){
							$benren['darenxiajipiaoshu']="500000";	
						}else{
							if($benren['darenpiaoshu']<"1000000"){
								$benren['darenxiajipiaoshu']="1000000";	
							}else{
								if($benren['darenpiaoshu']<"2000000"){
									$benren['darenxiajipiaoshu']="2000000";	
								}else{
									if($benren['darenpiaoshu']<"5000000"){
										$benren['darenxiajipiaoshu']="5000000";	
									}else{
										if($benren['darenpiaoshu']<"8000000"){
											$benren['darenxiajipiaoshu']="8000000";	
										}else{
											$benren['darenxiajipiaoshu']="10000000";
										}										
									}		
								}	
							}	
						}
					}
				}
			}	
		}
		$benren['darenpiaoshujindutiao']=$benren['darenpiaoshu']/$benren['darenxiajipiaoshu']*"160";
		//模板显示
			if($benren['muban']=="5"){
				$nowtime=date("H",time());
				if($nowtime>="6" && $nowtime<="18"){
					$mubanshezhi=M('pifu')->find("5");	
				}else{
					$mubanshezhi=M('pifu')->find("6");
				}
			}else{
			$mubanshezhi=M('pifu')->find($benren['muban']);
			}
			$benren['mubantupian']=$mubanshezhi['tupian'];
			$benrenpingbizhuangtai=M('pingbi')->where("zhu_id=".$_SESSION['user_id']." and bei_id=".$_GET['quid']."")->select();
			if($benrenpingbizhuangtai==""){
				$benren['pingbizhuangtai']="0";
			}else{
				$benren['pingbizhuangtai']="1";
			}
		$this->assign('benren',$benren);
			 $daren=M('daren')->find($benren['daren']);

			 $this->assign('daren',$daren);
			$chenghao=M('chenghao')->find($benren['chenghao']);
			$this->assign('chenghao',$chenghao);
		
		
		//频道列表
		$pindao = M('pindao')->order('id asc')->select();
		foreach($pindao as $k => $v){
			$pindao[$k]['weiboshu'] = M('weibo')->where("zuozhe=$id and pindao=$v[id]")->count();
		}
		$this->assign('pindao',$pindao);
		
		//访客首页左下广告位
		$fksyzxggw = M('guanggaowei')->find(31);
		$this->assign('fksyzxggw',$fksyzxggw);
		//访客首页广告轮播
		$fksygglb1 = M('guanggaowei')->find(26);
		$this->assign('fksygglb1',$fksygglb1);
		$fksygglb2 = M('guanggaowei')->find(27);
		$this->assign('fksygglb2',$fksygglb2);
		$fksygglb3 = M('guanggaowei')->find(28);
		$this->assign('fksygglb3',$fksygglb3);
		$fksygglb4 = M('guanggaowei')->find(29);
		$this->assign('fksygglb4',$fksygglb4);
		$fksygglb5 = M('guanggaowei')->find(30);
		$this->assign('fksygglb5',$fksygglb5);
		
		//微博列表
		$weiboid=$_GET["weiboid"];
		if($weiboid){
			//单条微博，微博详情
				$list = M('weibo')->where("id=$weiboid")->select();
				 foreach($list as $k=>$v){
					foreach($list[$k] as $ks=>$vs){
						if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
						$list[$k][$ks]=stripslashes($vs); 
						} 
					}
					
						$list[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
							foreach($list[$k]['pinglun'] as $kk=>$vv){
								$fasongzhe=M('user')->find($vv['fasongzhe']);
								$list[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
								$list[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
								$list[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
								foreach($list[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
									$nicheng=M('user')->find($vvv['fasongzhe']);
									$list[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
									$list[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
								}
							}
					 
					 $zuozhe=M('user')->find($v['zuozhe']);
					 $list[$k]['user_name']=$zuozhe['nicheng'];
					 $list[$k]['user_touxiang']=$zuozhe['touxiang'];
					 
					 $pindao=M('pindao')->find($v['pindao']);
					 $list[$k]['pindao_tupian']=$pindao['tupian'];
					 //时间格式转换开始			 
					 if(date("YmdHi",$list[$k]['time'])==date("YmdHi",time())){
						 $list[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$list[$k]['time'])."秒前";	 
					 }else{
						 if(date("YmdH",$list[$k]['time'])==date("YmdH",time())){
							 $list[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$list[$k]['time'])."分钟前"; 
						 }else{
							 if(date("Ymd",$list[$k]['time'])==date("Ymd",time())){
								 $list[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$list[$k]['time'])."小时前"; 
							 }else{
								 if(date("Y",$list[$k]['time'])==date("Y",time())){
									 $list[$k]['fabushijian']=date("m月d日 H:i",$list[$k]['time']);
								 }else{
									 $list[$k]['fabushijian']=date("Y年m月d日 H:i",$list[$k]['time']);
								 }
							 } 
						 }
					 }
					 //时间格式转换结束
					 if($list[$k]['zhuanfazhe']>"0"){
						 $yuanweibo=M('weibo')->find($v['suoshuweibo_id']);
						 $list[$k]['zhuanfa_content']=$yuanweibo['content'];
						 $list[$k]['zhuanfa_tupian1']=$yuanweibo['tupian1'];
						 $list[$k]['zhuanfa_tupian2']=$yuanweibo['tupian2'];
						 $list[$k]['zhuanfa_tupian3']=$yuanweibo['tupian3'];
						 $list[$k]['zhuanfa_tupian4']=$yuanweibo['tupian4'];
						 $list[$k]['zhuanfa_tupian5']=$yuanweibo['tupian5'];
						 $list[$k]['zhuanfa_tupian6']=$yuanweibo['tupian6'];
						 $list[$k]['zhuanfa_shipin']=$yuanweibo['shipin'];
						 $list[$k]['zhuanfa_changweibo']=$yuanweibo['changweibo'];
						 $yuanzuozhe=M('user')->find($v['suoshuzuozhe_id']);
						 $list[$k]['zhuanfa_yuanzuozhe_nicheng']=$yuanzuozhe['nicheng'];
						 $list[$k]['zhuanfa_yuanzuozhe_touxiang']=$yuanzuozhe['touxiang'];
					 }
					 if($list[$k]['jiajing']=="1"){
						 $list[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
					 }else{
						 $list[$k]['jingpinbiaozhi']="";
					 }
					 if($list[$k]['tuijian']=="1"){
						 $list[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
					 }else{
						 $list[$k]['tuijianbiaozhi']="";
					 }
	
				 }	
		}else{
			//微博列表
			$pindaoid=$_GET["pindaoid"];
			if($pindaoid==""){
			 import("@.ORG.Page");
				$count	= M('weibo')->where("zuozhe=$id")->count();
				$Page	= New Page($count,12);
				$show	= $Page->show();
				
				
				$list = M('weibo')->where("zuozhe=$id")->order('zhiding desc,zhitime desc,time desc')->limit($Page->firstRow.','.$Page->listRows)->select();
				 foreach($list as $k=>$v){
					foreach($list[$k] as $ks=>$vs){
						if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
						$list[$k][$ks]=stripslashes($vs); 
						} 
					}
					
						$list[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
							foreach($list[$k]['pinglun'] as $kk=>$vv){
								$fasongzhe=M('user')->find($vv['fasongzhe']);
								$list[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
								$list[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
								$list[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
								foreach($list[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
									$nicheng=M('user')->find($vvv['fasongzhe']);
									$list[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
									$list[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
								}
							}
					 
					 $zuozhe=M('user')->find($v['zuozhe']);
					 $list[$k]['user_name']=$zuozhe['nicheng'];
					 $list[$k]['user_touxiang']=$zuozhe['touxiang'];
					 
					 $pindao=M('pindao')->find($v['pindao']);
					 $list[$k]['pindao_tupian']=$pindao['tupian'];
					 //时间格式转换开始			 
					 if(date("YmdHi",$list[$k]['time'])==date("YmdHi",time())){
						 $list[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$list[$k]['time'])."秒前";	 
					 }else{
						 if(date("YmdH",$list[$k]['time'])==date("YmdH",time())){
							 $list[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$list[$k]['time'])."分钟前"; 
						 }else{
							 if(date("Ymd",$list[$k]['time'])==date("Ymd",time())){
								 $list[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$list[$k]['time'])."小时前"; 
							 }else{
								 if(date("Y",$list[$k]['time'])==date("Y",time())){
									 $list[$k]['fabushijian']=date("m月d日 H:i",$list[$k]['time']);
								 }else{
									 $list[$k]['fabushijian']=date("Y年m月d日 H:i",$list[$k]['time']);
								 }
							 } 
						 }
					 }
					 //时间格式转换结束
					 if($list[$k]['zhuanfazhe']>"0"){
						 $yuanweibo=M('weibo')->find($v['suoshuweibo_id']);
						 $list[$k]['zhuanfa_content']=$yuanweibo['content'];
						 $list[$k]['zhuanfa_tupian1']=$yuanweibo['tupian1'];
						 $list[$k]['zhuanfa_tupian2']=$yuanweibo['tupian2'];
						 $list[$k]['zhuanfa_tupian3']=$yuanweibo['tupian3'];
						 $list[$k]['zhuanfa_tupian4']=$yuanweibo['tupian4'];
						 $list[$k]['zhuanfa_tupian5']=$yuanweibo['tupian5'];
						 $list[$k]['zhuanfa_tupian6']=$yuanweibo['tupian6'];
						 $list[$k]['zhuanfa_shipin']=$yuanweibo['shipin'];
						 $list[$k]['zhuanfa_changweibo']=$yuanweibo['changweibo'];
						 $yuanzuozhe=M('user')->find($v['suoshuzuozhe_id']);
						 $list[$k]['zhuanfa_yuanzuozhe_nicheng']=$yuanzuozhe['nicheng'];
						 $list[$k]['zhuanfa_yuanzuozhe_touxiang']=$yuanzuozhe['touxiang'];
					 }
					 if($list[$k]['jiajing']=="1"){
						 $list[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
					 }else{
						 $list[$k]['jingpinbiaozhi']="";
					 }
					 if($list[$k]['tuijian']=="1"){
						 $list[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
					 }else{
						 $list[$k]['tuijianbiaozhi']="";
					 }
	
				 }	
				
			}else{
			 import("@.ORG.Page");
				$count	= M('weibo')->where("zuozhe=$id and pindao=$pindaoid")->count();
				$Page	= New Page($count,12);
				$show	= $Page->show();
				
				
				$list = M('weibo')->where("zuozhe=$id and pindao=$pindaoid")->order('zhiding desc,zhitime desc,time asc')->limit($Page->firstRow.','.$Page->listRows)->select();
				 foreach($list as $k=>$v){
					foreach($list[$k] as $ks=>$vs){
						if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
						$list[$k][$ks]=stripslashes($vs); 
						} 
					}
					 
					 $zuozhe=M('user')->find($v['zuozhe']);
					 $list[$k]['user_name']=$zuozhe['nicheng'];
					 $list[$k]['user_touxiang']=$zuozhe['touxiang'];
					 
					 $pindao=M('pindao')->find($v['pindao']);
					 $list[$k]['pindao_tupian']=$pindao['tupian'];
					 //时间格式转换开始			 
					 if(date("YmdHi",$list[$k]['time'])==date("YmdHi",time())){
						 $list[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$list[$k]['time'])."秒前";	 
					 }else{
						 if(date("YmdH",$list[$k]['time'])==date("YmdH",time())){
							 $list[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$list[$k]['time'])."分钟前"; 
						 }else{
							 if(date("Ymd",$list[$k]['time'])==date("Ymd",time())){
								 $list[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$list[$k]['time'])."小时前"; 
							 }else{
								 if(date("Y",$list[$k]['time'])==date("Y",time())){
									 $list[$k]['fabushijian']=date("m月d日 H:i",$list[$k]['time']);
								 }else{
									 $list[$k]['fabushijian']=date("Y年m月d日 H:i",$list[$k]['time']);
								 }
							 } 
						 }
					 }
					 //时间格式转换结束
					 if($list[$k]['zhuanfazhe']>"0"){
						 $yuanweibo=M('weibo')->find($v['suoshuweibo_id']);
						 $list[$k]['zhuanfa_content']=$yuanweibo['content'];
						 $list[$k]['zhuanfa_tupian1']=$yuanweibo['tupian1'];
						 $list[$k]['zhuanfa_tupian2']=$yuanweibo['tupian2'];
						 $list[$k]['zhuanfa_tupian3']=$yuanweibo['tupian3'];
						 $list[$k]['zhuanfa_tupian4']=$yuanweibo['tupian4'];
						 $list[$k]['zhuanfa_tupian5']=$yuanweibo['tupian5'];
						 $list[$k]['zhuanfa_tupian6']=$yuanweibo['tupian6'];
						 $list[$k]['zhuanfa_shipin']=$yuanweibo['shipin'];
						 $list[$k]['zhuanfa_changweibo']=$yuanweibo['changweibo'];
						 $yuanzuozhe=M('user')->find($v['suoshuzuozhe_id']);
						 $list[$k]['zhuanfa_yuanzuozhe_nicheng']=$yuanzuozhe['nicheng'];
						 $list[$k]['zhuanfa_yuanzuozhe_touxiang']=$yuanzuozhe['touxiang'];
					 }
					 if($list[$k]['jiajing']=="1"){
						 $list[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
					 }else{
						 $list[$k]['jingpinbiaozhi']="";
					 }
					 if($list[$k]['tuijian']=="1"){
						 $list[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
					 }else{
						 $list[$k]['tuijianbiaozhi']="";
					 }
				 }
			}
	
				 
					 
			 $this->assign('list',$list);
			 $this->assign('page',$show);
		}
		$this->assign('list',$list);
		$this->display();	 
	}
	//加黑名单
	function jiaheimingdan(){
		$chc="已拉黑";
		$heimingdan['bei_id']=$_POST['cid'];
		$heimingdan['zhu_id']=$_SESSION['user_id'];
		$heimingdan['ctime']=time();
		$yiyouheimingdan=M('heimingdan')->where("zhu_id=".$heimingdan['zhu_id']." and bei_id=".$heimingdan['bei_id']."")->select();
		if($yiyouheimingdan==""){
			
			$ids = $_POST['cid'];
			$idss = $_SESSION['user_id'];
			$del = M('haoyou')->where("bei_id=$ids and zhu_id=$idss")->delete();
			echo $del?'1':'0';
			$dels = M('haoyou')->where("zhu_id=$ids and bei_id=$idss")->delete();
			echo $dels?'1':'0';

			M('heimingdan')->add($heimingdan);
			
		}	
		echo  json_encode($chc);
	}
	//加屏蔽
	function jiapingbi(){
		$chc="已屏蔽";
		$pingbi['bei_id']=$_POST['cid'];
		$pingbi['zhu_id']=$_SESSION['user_id'];
		$pingbi['ctime']=time();
		$yiyoupingbi=M('pingbi')->where("zhu_id=".$pingbi['zhu_id']." and bei_id=".$pingbi['bei_id']."")->select();
		if($yiyoupingbi==""){
			M('pingbi')->add($pingbi);
		}	
		echo  json_encode($chc);
	}
	//取消屏蔽
	function jianpingbi(){
		$chc="已取消";
			$ids = $_POST['cid'];
			$idss = $_SESSION['user_id'];
			$del = M('pingbi')->where("bei_id=$ids and zhu_id=$idss")->delete();
		echo  json_encode($chc);
	}
	//加好友
	function jiahaoyou(){
		$haoyou['bei_id']=$_POST['cid'];
		$haoyou['zhu_id']=$_SESSION['user_id'];
		$yiyouhaoyou=M('haoyou')->where("zhu_id=".$haoyou['zhu_id']." and bei_id=".$haoyou['bei_id']."")->select();
		$yiyouhaoyou_dai=M('haoyou_dai')->where("zhu_id=".$haoyou['zhu_id']." and bei_id=".$haoyou['bei_id']."")->select();
		$ids = $_POST['cid'];
		$idss = $_SESSION['user_id'];
		$heimingdan=M('heimingdan')->where("zhu_id=ids and bei_id=$idss")->select();
		if($yiyouhaoyou=="" && $heimingdan=="" && $yiyouhaoyou_dai==""){
			M('haoyou_dai')->add($haoyou);
		}
		$cac="已申请";	
		echo  json_encode($cac);
	}
	//访客首页加收藏
	function shoucangjia(){
		if($_SESSION['user_id']!=""){
			$shoucang['weibo_id']=$_POST["cid"];
			$shoucang['user_id']=$_SESSION['user_id'];
			$shoucang['ctime']=time();
			$yiyoushoucang=M('shoucang')->where("weibo_id=".$shoucang['weibo_id']." and user_id=".$shoucang['user_id']."")->select();
			if($yiyoushoucang==""){
				M('shoucang')->add($shoucang);
			}
			$ccc="已收藏";	
		}else{
			$ccc="请登录";
		}
		echo  json_encode($ccc);
		
	}
	//访客首页达人赞
	function darenzanjia(){
		$userzhu['id']=$_SESSION['user_id'];
		$userzhuyuan=M('user')->find($userzhu['id']);
		if($userzhuyuan['darentoupiaocishu']>0){
			$user['id']=$_POST["cid"];
			$useryuan=M('user')->find($_POST['cid']);
			$user['darenzan']=$useryuan['darenzan']+1;
			$user['darenpiaoshu']=$useryuan['darenpiaoshu']+1;
				M('user')->save($user);
			$userzhu['darentoupiaocishu']=$userzhuyuan['darentoupiaocishu']-1;
				M('user')->save($userzhu);
			$ccc=$user['darenzan'];	
			echo  json_encode($ccc);
		}
	}
	//访客首页达人踩
	function darencaijia(){
		$userzhu['id']=$_SESSION['user_id'];
		$userzhuyuan=M('user')->find($userzhu['id']);
		if($userzhuyuan['darentoupiaocishu']>0){
			$user['id']=$_POST["cid"];
			$useryuan=M('user')->find($_POST['cid']);
			$user['darencai']=$useryuan['darencai']+1;
			$user['darenpiaoshu']=$useryuan['darenpiaoshu']+1;
				M('user')->save($user);
			$userzhu['darentoupiaocishu']=$userzhuyuan['darentoupiaocishu']-1;
				M('user')->save($userzhu);
			$ccc=$user['darencai'];	
			echo  json_encode($ccc);
		}
	}
	//访客首页置顶页首
	function zhiding(){
		$weibo['id']=$_POST["cid"];
		$weibo['zhiding']="1";
		$weibo['zhitime']=time();
		if($_SESSION['user_id']==$_SESSION['quid']){
			$user=M('user')->find($_SESSION['user_id']);
			if($user['zhidingcishu']>=1){
				$user['zhidingcishu']=$user['zhidingcishu']-1;			
				M('weibo')->save($weibo);	
				M('user')->save($user);
				$ccc="已置顶";	
			}else{
				$ccc="无次数";
			}
			echo  json_encode($ccc);
		}else{
			$this->error('非本人不能进行此操作！');	
		}
		
	}
	//访客首页置顶页首
	function quxiaozhiding(){
		$weibo['id']=$_POST["cid"];
		$weibo['zhiding']="0";
		$weibo['zhitime']="0";
		if($_SESSION['user_id']==$_SESSION['quid']){
			$user=M('user')->find($_SESSION['user_id']);
				$user['zhidingcishu']=$user['zhidingcishu']+1;			
				M('weibo')->save($weibo);	
				M('user')->save($user);
				$ccc="已取消";	
			echo  json_encode($ccc);
		}else{
			$this->error('非本人不能进行此操作！');	
		}
		
	}
	//访客首页发私信
	function dosixin2(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['time']=time();
		$_POST['fasongzhe']=$_SESSION['user_id'];
		$jieshounicheng=$_POST['nicheng'];
		$jieshouid=M('user')->where("nicheng='$jieshounicheng'")->find();
		$_POST['jieshouzhe']=$jieshouid['id'];
		$_POST['sixin_id']="0";
		
		if($_POST['nicheng']=='' || $_POST['content']==''){
			$this->error("信息不完整");	
		}
		      if( M('sixin')->add($_POST) ){
					$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
					$this->success('私信发送成功！');
			  }else{
					$this->error('私信发送失败！');
			  }
	    
	}
	//访客首页、个人微博、个人微博首页 转发微博
	function dozhuanfaweibo(){
	    header("Content-Type:text/html; charset=utf-8");

		$zhuanfa['time']=time();
		$zhuanfa['zhuanfazhe']=$_SESSION['user_id'];
		$weiboid=$_POST['weibo_id'];
		$yuanweibo=M('weibo')->find($weiboid);
		$zhuanfa['zuozhe']=$_SESSION['user_id'];
		$zhuanfa['content']=$_POST['content'];		
		$zhuanfa['yuedushu']="0";
		$zhuanfa['zanshu']="0";
		$zhuanfa['caishu']="0";
		$zhuanfa['pindao']=$yuanweibo['pindao'];
		$zhuanfa['tuijian']="0";
		$zhuanfa['jiajing']="0";
		$zhuanfa['wenzilian']="0";
		$zhuanfa['ttime']="0";
		$zhuanfa['jtime']="0";
		$zhuanfa['wtime']="0";
		$zhuanfa['wenzi']="";
		$zhuanfa['zhiding']="0";
		$zhuanfa['zhitime']="0";
		$zhuanfa['suoshuweibo_id']=$yuanweibo['id'];
		$zhuanfa['suoshuzuozhe_id']=$yuanweibo['zuozhe'];
			
		if($zhuanfa['zhuanfazhe']=='0' || $zhuanfa['zuozhe']=='0' || $zhuanfa['suoshuweibo_id']=='0' ){
			$this->error("信息不完整");	
		}
		if($_SESSION['user_id']!=""){
			  if( M('weibo')->add($zhuanfa) ){
					$useryuan=M('user')->find($_SESSION['user_id']);  
					if($useryuan['zhuanfacishu']>=1){
						$user['id']=$_SESSION['user_id'];
						$user['zhuanfacishu']=$useryuan['zhuanfacishu']-1;
						$user['jifen']=$useryuan['jifen']+1;
						M('user')->save($user);
					}	
					$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
					$this->success('转发成功！');
			  }else{
					$this->error('转发失败！');
			  }
		}else{
			$this->error("请登录");	
		}
		
	}

	//访客首页修改分类
	function doxiugaifenlei(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['id']=$_POST['weibo_id'];
		$_POST['pindao']=$_POST['weibo_pindao'];		
		if($_POST['id']=='' || $_POST['pindao']==''){
			$this->error("信息不完整");	
		}
		if($_SESSION['user_id']==$_SESSION['quid']){
		      if( M('weibo')->save($_POST) ){
					$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
					$this->success('修改成功！');
			  }else{
					$this->error('修改失败！');
			  }
		}else{
			$this->error('非本人不能进行此操作！');
		}
	    
	}
	//访客首页删除微博
	function delshanchuweibo(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$id=$_POST['weibo_id'];

		if($_SESSION['user_id']==$_SESSION['quid']){
		      if( M('weibo')->where("id IN ($id)")->delete() ){
					$this->assign('jumpUrl', U('fksy',array(quid=>$_SESSION['quid'])));
					$this->success('删除成功！');
			  }else{
					$this->error('删除失败！');
			  }
		}else{
			$this->error('非本人不能进行此操作！');
		}
	    
	}
		
	function hy(){
		$id=$_SESSION['user_id'];
		//好友
		 import("@.ORG.Page");
		 	$count	= M('haoyou')->where("zhu_id=$id and bei_id!=$id")->count();
			$Page	= New Page($count,12);
			$show	= $Page->show();

		$haoyou = M('haoyou')->where("zhu_id=$id and bei_id!=$id")->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
			foreach($haoyou as $k=>$v){
				$haoyouss=M('user')->find($v['bei_id']);
				$haoyou[$k]['name']=$haoyouss['nicheng'];
				$haoyou[$k]['touxiang']=$haoyouss['touxiang'];
					if($haoyouss['xingbie']=='1'){
					$haoyou[$k]['xingbie']="男";
					}
					if($haoyouss['xingbie']=='2'){
					$haoyou[$k]['xingbie']="女";
					}
				
				$sheng_name=M('city')->find($haoyouss['sheng']);
				$haoyou[$k]['sheng_name']=$sheng_name['city_name'];
				$shi_name=M('city')->find($haoyouss['shi']);
				$haoyou[$k]['shi_name']=$shi_name['city_name'];
					if($haoyouss['gexingxuanyan']==""){
					$haoyou[$k]['gexingxuanyan']="您的该好友还没有填写个人简介";	
					}else{
					$haoyou[$k]['gexingxuanyan']=$haoyouss['gexingxuanyan'];
					}
			}
		
		$this->assign('haoyou',$haoyou);
		$this->assign('page',$show);
		$daihaoyoushu=M('haoyou_dai')->where("bei_id=$id")->count();
		$this->assign('daihaoyoushu',$daihaoyoushu);
		$this->assign('haoyoushu',$count);
		$this->display();
			 
	}
	function delhaoyou(){
	    $ids = $_POST['ids'];
		$del = M('haoyou')->where("id IN ($ids)")->delete();
        echo $del?'1':'0';
	}
	//待通过申请好友
	function daihy(){
		$id=$_SESSION['user_id'];
		//好友
		 import("@.ORG.Page");
		 	$count	= M('haoyou_dai')->where("bei_id=$id")->count();
			$Page	= New Page($count,12);
			$show	= $Page->show();

		$haoyou = M('haoyou_dai')->where("bei_id=$id")->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
			foreach($haoyou as $k=>$v){
				$haoyouss=M('user')->find($v['zhu_id']);
				$haoyou[$k]['name']=$haoyouss['nicheng'];
				$haoyou[$k]['touxiang']=$haoyouss['touxiang'];
					if($haoyouss['xingbie']=='1'){
					$haoyou[$k]['xingbie']="男";
					}
					if($haoyouss['xingbie']=='2'){
					$haoyou[$k]['xingbie']="女";
					}
				
				$sheng_name=M('city')->find($haoyouss['sheng']);
				$haoyou[$k]['sheng_name']=$sheng_name['city_name'];
				$shi_name=M('city')->find($haoyouss['shi']);
				$haoyou[$k]['shi_name']=$shi_name['city_name'];
					if($haoyouss['gexingxuanyan']==""){
					$haoyou[$k]['gexingxuanyan']="您的该好友还没有填写个人简介";	
					}else{
					$haoyou[$k]['gexingxuanyan']=$haoyouss['gexingxuanyan'];
					}
			}
		
		$this->assign('haoyou',$haoyou);
		$this->assign('page',$show);
		$daihaoyoushu=M('haoyou_dai')->where("bei_id=$id")->count();
		$this->assign('daihaoyoushu',$daihaoyoushu);
		$haoyoushusss=M('haoyou')->where("zhu_id=$id and bei_id!=$id")->count();
		$this->assign('haoyoushu',$haoyoushusss);
		$this->display();
			 
	}
	function tongyihaoyou(){
	    $ids = $_POST['ids'];
		$idss = $_SESSION['user_id'];
		$haoyou['zhu_id'] = $ids;
		$haoyou['bei_id'] = $idss;
		M('haoyou')->add($haoyou);
		$yiyouhaoyou=M('haoyou')->where("zhu_id=$idss and bei_id=$ids")->select();
		if($yiyouhaoyou==""){
			$haoyous['zhu_id'] = $idss;
			$haoyous['bei_id'] = $ids;
			M('haoyou')->add($haoyous);
		}
		$del = M('haoyou_dai')->where("zhu_id=$ids and bei_id=$idss")->delete();
        echo $del?'1':'0';
	}
	function huluehaoyou(){
	    $ids = $_POST['ids'];
		$idss = $_SESSION['user_id'];
		$del = M('haoyou_dai')->where("zhu_id=$ids and bei_id=$idss")->delete();
        echo $del?'1':'0';
	}

	function pcxx(){
		$id=$_SESSION['user_id'];
		 import("@.ORG.Page");
		 	$count	= M('sixin')->where("jieshouzhe=$id and sixin_id=0")->count();
			$Page	= New Page($count,10);
			$show	= $Page->show();

		$sixin = M('sixin')->where("jieshouzhe=$id and sixin_id=0")->order('time desc')->limit($Page->firstRow.','.$Page->listRows)->select();
			foreach($sixin as $k=>$v){
				$fasongzhe=M('user')->find($v['fasongzhe']);
				$sixin[$k]['fasongname']=$fasongzhe['nicheng'];
				$sixin[$k]['fasongtouxiang']=$fasongzhe['touxiang'];
				$sixin[$k]['sixinhuifu']=M('sixin')->where("sixin_id='".$v['id']."'")->order('time asc')->select();
				foreach($sixin[$k]['sixinhuifu'] as $kk=>$vv){
					$nicheng=M('user')->find($vv['fasongzhe']);
					$sixin[$k]['sixinhuifu'][$kk]['fasongname']=$nicheng['nicheng'];
					$sixin[$k]['sixinhuifu'][$kk]['fasongtouxiang']=$nicheng['touxiang'];		
				}
			}

		$this->assign('sixin',$sixin);
		$this->assign('page',$show);

		$this->display();	 
	}
	//发私信
	function dosixin(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['time']=time();
		$_POST['fasongzhe']=$_SESSION['user_id'];
		$jieshounicheng=$_POST['nicheng'];
		$jieshouid=M('user')->where("nicheng='$jieshounicheng'")->find();
		$_POST['jieshouzhe']=$jieshouid['id'];
		$_POST['sixin_id']="0";
		if($_POST['nicheng']=='' || $_POST['content']==''){
			$this->error("信息不完整");	
		}
		      if( M('sixin')->add($_POST) ){
					$this->assign('jumpUrl', U('pcxx'));
					$this->success('私信发送成功！');
			  }else{
					$this->error('私信发送失败！');
			  }
	    
	}

	//发私信回复
	function dosixinhuifu(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['time']=time();
		$_POST['fasongzhe']=$_SESSION['user_id'];
		$fasong=$_POST['sixin_id'];
		$fasongid=M('sixin')->find($fasong);
		$_POST['jieshouzhe']=$fasongid['fasongzhe'];
		if($_POST['content']==''){
			$this->error("信息不完整");	
		}
		      if( M('sixin')->add($_POST) ){
					$this->assign('jumpUrl', U('pcxx'));
					$this->success('私信发送成功！');
			  }else{
					$this->error('私信发送失败！');
			  }
	    
	}	
	//评论
	function pl(){
		$id=$_SESSION['user_id'];
		 import("@.ORG.Page");
		 	$count	= M('pinglun')->where("jieshouzhe=$id and pinglun_id=0")->count();
			$Page	= New Page($count,10);
			$show	= $Page->show();

		$pinglun = M('pinglun')->where("jieshouzhe=$id and pinglun_id=0")->order('time desc')->limit($Page->firstRow.','.$Page->listRows)->select();
			foreach($pinglun as $k=>$v){
				$fasongzhe=M('user')->find($v['fasongzhe']);
				$pinglun[$k]['fasongname']=$fasongzhe['nicheng'];
				$pinglun[$k]['fasongtouxiang']=$fasongzhe['touxiang'];
				$pinglun[$k]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$v['id']."'")->order('time asc')->select();
				foreach($pinglun[$k]['pinglunhuifu'] as $kk=>$vv){
					$nicheng=M('user')->find($vv['fasongzhe']);
					$pinglun[$k]['pinglunhuifu'][$kk]['fasongname']=$nicheng['nicheng'];
					$pinglun[$k]['pinglunhuifu'][$kk]['fasongtouxiang']=$nicheng['touxiang'];		
				}
			}

		$this->assign('pinglun',$pinglun);
		$this->assign('page',$show);

		$this->display();	 
	}
	//评论fachu
	function plfc(){
		$id=$_SESSION['user_id'];
		 import("@.ORG.Page");
		 	$count	= M('pinglun')->where("fasongzhe=$id and pinglun_id=0")->count();
			$Page	= New Page($count,10);
			$show	= $Page->show();

		$pinglun = M('pinglun')->where("fasongzhe=$id and pinglun_id=0")->order('time desc')->limit($Page->firstRow.','.$Page->listRows)->select();
			foreach($pinglun as $k=>$v){
				$fasongzhe=M('user')->find($v['fasongzhe']);
				$pinglun[$k]['fasongname']=$fasongzhe['nicheng'];
				$pinglun[$k]['fasongtouxiang']=$fasongzhe['touxiang'];
				$pinglun[$k]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$v['id']."'")->order('time asc')->select();
				foreach($pinglun[$k]['pinglunhuifu'] as $kk=>$vv){
					$nicheng=M('user')->find($vv['fasongzhe']);
					$pinglun[$k]['pinglunhuifu'][$kk]['fasongname']=$nicheng['nicheng'];
					$pinglun[$k]['pinglunhuifu'][$kk]['fasongtouxiang']=$nicheng['touxiang'];		
				}
			}

		$this->assign('pinglun',$pinglun);
		$this->assign('page',$show);

		$this->display();	 
	}

	//发评论回复
	function dopinglunhuifu(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['time']=time();
		$_POST['fasongzhe']=$_SESSION['user_id'];
		$fasong=$_POST['pinglun_id'];
		$fasongid=M('pinglun')->find($fasong);
		$_POST['jieshouzhe']=$fasongid['fasongzhe'];
		$_POST['weibo_id']=$fasongid['weibo_id'];
		if($_POST['content']==''){
			$this->error("信息不完整");	
		}
		      if( M('pinglun')->add($_POST) ){
					$useryuan=M('user')->find($_SESSION['user_id']);  
					if($useryuan['pingluncishu']>=1){
						$user['id']=$_SESSION['user_id'];
						$user['pingluncishu']=$useryuan['pingluncishu']-1;
						$user['jifen']=$useryuan['jifen']+1;
						M('user')->save($user);
					}	

					$this->success('评论成功！');
			  }else{
					$this->error('评论失败！');
			  }
	    
	}	
	//个人微博首页发评论
	function dopinglun(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['time']=time();
		$_POST['fasongzhe']=$_SESSION['user_id'];
		$fasong=$_POST['weibo_id'];
		$fasongid=M('weibo')->find($fasong);
		$_POST['jieshouzhe']=$fasongid['zuozhe'];
		$_POST['pinglun_id']="0";
		if($_POST['content']==''){
			$this->error("信息不完整");	
		}
		      if( M('pinglun')->add($_POST) ){
					$useryuan=M('user')->find($_SESSION['user_id']);  
					if($useryuan['pingluncishu']>=1){
						$user['id']=$_SESSION['user_id'];
						$user['pingluncishu']=$useryuan['pingluncishu']-1;
						$user['jifen']=$useryuan['jifen']+1;
						M('user')->save($user);
					}	
					$this->success('评论成功！');
			  }else{
					$this->error('评论失败！');
			  }
	    
	}	
	//个人微博首页发评论回复
	function dogrwbsypinglunhuifu(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['time']=time();
		$_POST['fasongzhe']=$_SESSION['user_id'];
		$fasong=$_POST['pinglun_id'];
		$fasongid=M('pinglun')->find($fasong);
		$_POST['jieshouzhe']=$fasongid['fasongzhe'];
		$_POST['weibo_id']=$fasongid['weibo_id'];
		if($_POST['content']==''){
			$this->error("信息不完整");	
		}
		      if( M('pinglun')->add($_POST) ){
					$useryuan=M('user')->find($_SESSION['user_id']);  
					if($useryuan['pingluncishu']>=1){
						$user['id']=$_SESSION['user_id'];
						$user['pingluncishu']=$useryuan['pingluncishu']-1;
						$user['jifen']=$useryuan['jifen']+1;
						M('user')->save($user);
					}	
					$this->success('评论成功！');
			  }else{
					$this->error('评论失败！');
			  }
	    
	}
	
	function sc(){
		$id=$_SESSION['user_id'];
		 import("@.ORG.Page");
		 	$count	= M('shoucang')->where("user_id=$id")->count();
			$Page	= New Page($count,10);
			$show	= $Page->show();

		$shoucang = M('shoucang')->where("user_id=$id")->order('ctime desc')->limit($Page->firstRow.','.$Page->listRows)->select();
			foreach($shoucang as $k=>$v){
				$weibo=M('weibo')->find($v['weibo_id']);
				$shoucang[$k]['content']=$weibo['content'];
				$shoucang[$k]['yuedushu']=$weibo['yuedushu'];
				$shoucang[$k]['zanshu']=$weibo['zanshu'];
				$shoucang[$k]['caishu']=$weibo['caishu'];
				$shoucang[$k]['time']=$weibo['time'];
				$shoucang[$k]['zhuanfazhe']=$weibo['zhuanfazhe'];
				$shoucang[$k]['changweibo']=$weibo['changweibo'];
				$shoucang[$k]['pindao']=$weibo['pindao'];
				$shoucang[$k]['tuijian']=$weibo['tuijian'];
				$shoucang[$k]['jiajing']=$weibo['jiajing'];
				$shoucang[$k]['wenzilian']=$weibo['wenzilian'];
				$shoucang[$k]['ttime']=$weibo['ttime'];
				$shoucang[$k]['jtime']=$weibo['jtime'];
				$shoucang[$k]['wtime']=$weibo['wtime'];
				$shoucang[$k]['wenzi']=$weibo['wenzi'];
				$shoucang[$k]['zhiding']=$weibo['zhiding'];
				$shoucang[$k]['zhitime']=$weibo['zhitime'];
				$shoucang[$k]['suoshuweibo_id']=$weibo['suoshuweibo_id'];
				$shoucang[$k]['suoshuzuozhe_id']=$weibo['suoshuzuozhe_id'];
				$shoucang[$k]['tupian1']=$weibo['tupian1'];
				$shoucang[$k]['tupian2']=$weibo['tupian2'];
				$shoucang[$k]['tupian3']=$weibo['tupian3'];
				$shoucang[$k]['tupian4']=$weibo['tupian4'];
				$shoucang[$k]['tupian5']=$weibo['tupian5'];
				$shoucang[$k]['tupian6']=$weibo['tupian6'];
				$shoucang[$k]['shipin']=$weibo['shipin'];
				$shoucang[$k]['changweibo']=$weibo['changweibo'];
				 $shoucang[$k]['suoshuzuozhe_id']=$weibo['suoshuzuozhe_id'];
				 $shoucang[$k]['suoshuweibo_id']=$weibo['suoshuweibo_id'];
				
				$zuozhe=M('user')->find($weibo['zuozhe']);
				$shoucang[$k]['zuozhetouxiang']=$zuozhe['touxiang'];
				$shoucang[$k]['zuozhenicheng']=$zuozhe['nicheng'];
				$shoucang[$k]['zuozheid']=$zuozhe['id'];
				foreach($shoucang[$k] as $ks=>$vs){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$shoucang[$k][$ks]=stripslashes($vs); 
					} 
				}

					$shoucang[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['weibo_id']." and pinglun_id=0")->order('time desc')->select();
						foreach($shoucang[$k]['pinglun'] as $kk=>$vv){
							$fasongzhe=M('user')->find($vv['fasongzhe']);
							$shoucang[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
							$shoucang[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
							$shoucang[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
							foreach($shoucang[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
								$nicheng=M('user')->find($vvv['fasongzhe']);
								$shoucang[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
								$shoucang[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
							}
							
						}
				 //时间格式转换开始			 
				 if(date("YmdHi",$shoucang[$k]['time'])==date("YmdHi",time())){
				 	 $shoucang[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$shoucang[$k]['time'])."秒前";	 
				 }else{
					 if(date("YmdH",$shoucang[$k]['time'])==date("YmdH",time())){
						 $shoucang[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$shoucang[$k]['time'])."分钟前"; 
					 }else{
					  	 if(date("Ymd",$shoucang[$k]['time'])==date("Ymd",time())){
							 $shoucang[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$shoucang[$k]['time'])."小时前"; 
						 }else{
							 if(date("Y",$shoucang[$k]['time'])==date("Y",time())){
						 		 $shoucang[$k]['fabushijian']=date("m月d日 H:i",$shoucang[$k]['time']);
							 }else{
								 $shoucang[$k]['fabushijian']=date("Y年m月d日 H:i",$shoucang[$k]['time']);
							 }
						 } 
					 }
				 }
				 //时间格式转换结束
					 if($shoucang[$k]['jiajing']=="1"){
						 $shoucang[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
					 }else{
						 $shoucang[$k]['jingpinbiaozhi']="";
					 }
					 if($shoucang[$k]['tuijian']=="1"){
						 $shoucang[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
					 }else{
						 $shoucang[$k]['tuijianbiaozhi']="";
					 }
			 
				 $zuozhe=M('user')->find($weibo['zuozhe']);
				 $shoucang[$k]['user_name']=$zuozhe['nicheng'];
				 $shoucang[$k]['user_touxiang']=$zuozhe['touxiang'];
				 
				 $pindao=M('pindao')->find($weibo['pindao']);
				 $shoucang[$k]['pindao_tupian']=$pindao['tupian'];
				 
				 if($shoucang[$k]['zhuanfazhe']>"0"){
					 $yuanweibo=M('weibo')->find($weibo['suoshuweibo_id']);
					 $shoucang[$k]['zhuanfa_content']=$yuanweibo['content'];
					 $shoucang[$k]['zhuanfa_tupian1']=$yuanweibo['tupian1'];
					 $shoucang[$k]['zhuanfa_tupian2']=$yuanweibo['tupian2'];
					 $shoucang[$k]['zhuanfa_tupian3']=$yuanweibo['tupian3'];
					 $shoucang[$k]['zhuanfa_tupian4']=$yuanweibo['tupian4'];
					 $shoucang[$k]['zhuanfa_tupian5']=$yuanweibo['tupian5'];
					 $shoucang[$k]['zhuanfa_tupian6']=$yuanweibo['tupian6'];
					 $shoucang[$k]['zhuanfa_shipin']=$yuanweibo['shipin'];
					 $shoucang[$k]['zhuanfa_changweibo']=$yuanweibo['changweibo'];
					 $yuanzuozhe=M('user')->find($weibo['suoshuzuozhe_id']);
					 $shoucang[$k]['zhuanfa_yuanzuozhe_nicheng']=$yuanzuozhe['nicheng'];
					 $shoucang[$k]['zhuanfa_yuanzuozhe_touxiang']=$yuanzuozhe['touxiang'];
					 
				 }

			}

		$this->assign('shoucang',$shoucang);
		$this->assign('page',$show);

		$this->display();	 
	}
	//收藏页推荐首页
	function tuijianshouye(){
		$tuijian['id']=$_POST["cid"];
		$tuijian['tuijian']="1";
		$tuijian['ttime']=time();
		$yiyoutuijian=M('weibo')->where("id=".$tuijian['id']." and tuijian=1")->find();
		if($yiyoutuijian==""){
			M('weibo')->save($tuijian);
			
			$bei_weibo=M('weibo')->find($tuijian['id']);
			$bei_user=M('user')->find($bei_weibo['zuozhe']);
			$bei_user_xin['id']=$bei_user['id'];
			$bei_user_xin['jifen']=$bei_user['jifen']+5;
			M('user')->save($bei_user_xin);
		}
		$ccc="已推荐";	
		echo  json_encode($ccc);
	}
	//收藏页加精华
	function jiajinghua(){
		$jiajing['id']=$_POST["cid"];
		$jiajing['jiajing']="1";
		$jiajing['jtime']=time();
		$yiyoujiajing=M('weibo')->where("id=".$jiajing['id']." and jiajing=1")->find();
		if($yiyoujiajing==""){
			M('weibo')->save($jiajing);
			
			$bei_weibo=M('weibo')->find($jiajing['id']);
			$bei_user=M('user')->find($bei_weibo['zuozhe']);
			$bei_user_xin['id']=$bei_user['id'];
			$bei_user_xin['jifen']=$bei_user['jifen']+5;
			M('user')->save($bei_user_xin);			
		}
		$ccc="已加精";	
		echo  json_encode($ccc);
	}


	function ss(){
		$sousuoyeguanggaoweishang=M('guanggaowei')->find('32');
		$this->assign('sousuoyeguanggaoweishang',$sousuoyeguanggaoweishang);
		$sousuoyeguanggaoweixia=M('guanggaowei')->find('33');
		$this->assign('sousuoyeguanggaoweixia',$sousuoyeguanggaoweixia);
		//微博热搜榜
		$weiboresoubang=M('sousuojilu')->order('cishu desc,id desc')->limit('0,10')->select();
		$this->assign('weiboresoubang',$weiboresoubang);
		//搜索历史		
		$sousuolishi=M('sousuojilu')->where("zhu_id=".$_SESSION['user_id']."")->order('id desc')->limit('0,10')->select();
		$this->assign('sousuolishi',$sousuolishi);
		
		$this->display();	 
	}
	function tdwd(){
		$id=$_SESSION['user_id'];
		$userxinxi=M('user')->find($id);
		$wodenicheng="@".$userxinxi['nicheng'];
		$tdwdshezhi=M('user')->find($id);
		if($tdwdshezhi['atshezhi']==0){
			 import("@.ORG.Page");
				$count	= M('weibo')->where("content like '%$wodenicheng%'")->count();
				$Page	= New Page($count,10);
				$show	= $Page->show();
	
			$list = M('weibo')->where("content like '%$wodenicheng%'")->order('time desc')->limit($Page->firstRow.','.$Page->listRows)->select();
		}else{
			if($tdwdshezhi['atshezhi']==1){
				$haoyou = 	M('haoyou')->where("zhu_id=$id")->select();
				foreach($haoyou as $k=>$v){
				$haoyouss[$k]=$haoyou[$k]['bei_id'];
				}
				$haoyousss=implode(",",$haoyouss);
		
				 import("@.ORG.Page");
					$count	= M('weibo')->where("content like '%$wodenicheng%' and zuozhe IN ($haoyousss)")->count();
					$Page	= New Page($count,10);
					$show	= $Page->show();
		
				$list = M('weibo')->where("content like '%$wodenicheng%' and zuozhe IN ($haoyousss)")->order('time desc')->limit($Page->firstRow.','.$Page->listRows)->select();
			}else{
				 import("@.ORG.Page");
					$count	= M('weibo')->where("content like '%$wodenicheng%' and zuozhe=$id")->count();
					$Page	= New Page($count,10);
					$show	= $Page->show();
		
				$list = M('weibo')->where("content like '%$wodenicheng%' and zuozhe=$id")->order('time desc')->limit($Page->firstRow.','.$Page->listRows)->select();
	
			}		
		}
	         foreach($list as $k=>$v){
				foreach($list[$k] as $ks=>$vs){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$list[$k][$ks]=stripslashes($vs); 
					} 
				}

					$list[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
						foreach($list[$k]['pinglun'] as $kk=>$vv){
							$fasongzhe=M('user')->find($vv['fasongzhe']);
							$list[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
							$list[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
							$list[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
							foreach($list[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
								$nicheng=M('user')->find($vvv['fasongzhe']);
								$list[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
								$list[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
							}
							
						}
				 //时间格式转换开始			 
				 if(date("YmdHi",$list[$k]['time'])==date("YmdHi",time())){
				 	 $list[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$list[$k]['time'])."秒前";	 
				 }else{
					 if(date("YmdH",$list[$k]['time'])==date("YmdH",time())){
						 $list[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$list[$k]['time'])."分钟前"; 
					 }else{
					  	 if(date("Ymd",$list[$k]['time'])==date("Ymd",time())){
							 $list[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$list[$k]['time'])."小时前"; 
						 }else{
							 if(date("Y",$list[$k]['time'])==date("Y",time())){
						 		 $list[$k]['fabushijian']=date("m月d日 H:i",$list[$k]['time']);
							 }else{
								 $list[$k]['fabushijian']=date("Y年m月d日 H:i",$list[$k]['time']);
							 }
						 } 
					 }
				 }
				 //时间格式转换结束

					 if($list[$k]['jiajing']=="1"){
						 $list[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
					 }else{
						 $list[$k]['jingpinbiaozhi']="";
					 }
					 if($list[$k]['tuijian']=="1"){
						 $list[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
					 }else{
						 $list[$k]['tuijianbiaozhi']="";
					 }
				 $zuozhe=M('user')->find($v['zuozhe']);
				 $list[$k]['user_name']=$zuozhe['nicheng'];
				 $list[$k]['user_touxiang']=$zuozhe['touxiang'];
				 
				 $pindao=M('pindao')->find($v['pindao']);
				 $list[$k]['pindao_tupian']=$pindao['tupian'];
				 
				 if($list[$k]['zhuanfazhe']>"0"){
					 $yuanweibo=M('weibo')->find($v['suoshuweibo_id']);
					 $list[$k]['zhuanfa_content']=$yuanweibo['content'];
					 $list[$k]['zhuanfa_tupian1']=$yuanweibo['tupian1'];
					 $list[$k]['zhuanfa_tupian2']=$yuanweibo['tupian2'];
					 $list[$k]['zhuanfa_tupian3']=$yuanweibo['tupian3'];
					 $list[$k]['zhuanfa_tupian4']=$yuanweibo['tupian4'];
					 $list[$k]['zhuanfa_tupian5']=$yuanweibo['tupian5'];
					 $list[$k]['zhuanfa_tupian6']=$yuanweibo['tupian6'];
					 $list[$k]['zhuanfa_shipin']=$yuanweibo['shipin'];
					 $list[$k]['zhuanfa_changweibo']=$yuanweibo['changweibo'];
					 $yuanzuozhe=M('user')->find($v['suoshuzuozhe_id']);
					 $list[$k]['zhuanfa_yuanzuozhe_nicheng']=$yuanzuozhe['nicheng'];
					 $list[$k]['zhuanfa_yuanzuozhe_touxiang']=$yuanzuozhe['touxiang'];
				 }
			 }
		$this->assign('list',$list);
		$this->assign('page',$show);

		$this->display();	 
	}
	//@我的评论
	function tdwdpl(){
		$id=$_SESSION['user_id'];
		$userxinxi=M('user')->find($id);
		$wodenicheng="@".$userxinxi['nicheng'];
		$tdwdshezhi=M('user')->find($id);
		if($tdwdshezhi['atshezhi']==0){
			 import("@.ORG.Page");
				$count	= M('pinglun')->where("content like '%$wodenicheng%'")->count();
				$Page	= New Page($count,10);
				$show	= $Page->show();
	
			$pinglun = M('pinglun')->where("content like '%$wodenicheng%'")->order('time desc')->limit($Page->firstRow.','.$Page->listRows)->select();
		}else{
			if($tdwdshezhi['atshezhi']==1){
				$haoyou = 	M('haoyou')->where("zhu_id=$id")->select();
				foreach($haoyou as $k=>$v){
				$haoyouss[$k]=$haoyou[$k]['bei_id'];
				}
				$haoyousss=implode(",",$haoyouss);
		
				 import("@.ORG.Page");
					$count	= M('weibo')->where("content like '%$wodenicheng%' and fasongzhe IN ($haoyousss)")->count();
					$Page	= New Page($count,10);
					$show	= $Page->show();
		
				$pinglun = M('pinglun')->where("content like '%$wodenicheng%' and fasongzhe IN ($haoyousss)")->order('time desc')->limit($Page->firstRow.','.$Page->listRows)->select();
			}else{
				 import("@.ORG.Page");
					$count	= M('weibo')->where("content like '%$wodenicheng%' and fasongzhe=$id")->count();
					$Page	= New Page($count,10);
					$show	= $Page->show();
		
				$pinglun = M('pinglun')->where("content like '%$wodenicheng%' and fasongzhe=$id")->order('time desc')->limit($Page->firstRow.','.$Page->listRows)->select();
	
			}		
		}
		
			foreach($pinglun as $k=>$v){
				$fasongzhe=M('user')->find($v['fasongzhe']);
				$pinglun[$k]['fasongname']=$fasongzhe['nicheng'];
				$pinglun[$k]['fasongtouxiang']=$fasongzhe['touxiang'];
				$pinglun[$k]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$v['id']."'")->order('time asc')->select();
				foreach($pinglun[$k]['pinglunhuifu'] as $kk=>$vv){
					$nicheng=M('user')->find($vv['fasongzhe']);
					$pinglun[$k]['pinglunhuifu'][$kk]['fasongname']=$nicheng['nicheng'];
					$pinglun[$k]['pinglunhuifu'][$kk]['fasongtouxiang']=$nicheng['touxiang'];		
				}
			}

		$this->assign('pinglun',$pinglun);
		$this->assign('page',$show);

		$this->display();	 
	}

	function wzsm(){
		$id=$_GET['sm'];
		$wzsm=M('wzsm')->find($id);
		$this->assign($wzsm);
		$this->display();	 
	}
	 
	 //关于我们
	 function about(){
	      
		  $f = M('about')->find();
		  $this->assign($f);
	      $this->display();
	 }
	//搜索用户
	function sousuoyonghuming(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$sousuosousuoci=$_POST['sousuoci'];
		$_POST['zhu_id']=$_SESSION['user_id'];
		$_POST['cishu']="0";
		if($_POST['sousuoci']=='' || $_POST['sousuoci']==' ' || $_POST['sousuoci']=='  ' || $_POST['sousuoci']=='   ' || $_POST['sousuoci']=='    ' || $_POST['sousuoci']=='     ' || $_POST['sousuoci']=='      ' || $_POST['sousuoci']=='       ' || $_POST['sousuoci']=='        ' || $_POST['sousuoci']=='         ' || $_POST['sousuoci']=='          ' || $_POST['sousuoci']=='           ' || $_POST['sousuoci']=='            ' || $_POST['sousuoci']=='	' || $_POST['sousuoci']=='搜名字/广播'){
			$this->error("请输入搜索内容");	
		}
		if( M('sousuojilu')->add($_POST) ){
			
			$sousuoyuan=M('sousuojilu')->where("sousuoci='$sousuosousuoci'")->order('id asc')->limit('1')->find();  
			$sousuoxian['id']=$sousuoyuan['id'];
			$sousuoxian['cishu']=$sousuoyuan['cishu']+"1";
			M('sousuojilu')->save($sousuoxian);
		}
		//搜索用户名
		 import("@.ORG.Page");
		 	$count2	= M('user')->where("nicheng like '%$sousuosousuoci%'")->count();
			$Page2	= New Page($count2,12);
			$show2	= $Page2->show();
		$sousuoyonghu=M('user')->where("nicheng like '%$sousuosousuoci%'")->order('id asc')->limit($Page2->firstRow.','.$Page2->listRows)->select();
		foreach($sousuoyonghu as $k=>$v){
			$sheng_name=M('city')->find($v['sheng']);
			$sousuoyonghu[$k]['sheng_name']=$sheng_name['city_name'];
			$shi_name=M('city')->find($v['shi']);
			$sousuoyonghu[$k]['shi_name']=$shi_name['city_name'];
			if($v['xingbie']=="1"){
				$sousuoyonghu[$k]['xingbie']="男";
			}
			if($v['xingbie']=="2"){
				$sousuoyonghu[$k]['xingbie']="女";
			}
		}
		$this->assign('sousuoyonghu',$sousuoyonghu);
		$this->assign('page2',$show2);
		//广告位
		$sousuoyeguanggaoweishang=M('guanggaowei')->find('32');
		$this->assign('sousuoyeguanggaoweishang',$sousuoyeguanggaoweishang);
		$sousuoyeguanggaoweixia=M('guanggaowei')->find('33');
		$this->assign('sousuoyeguanggaoweixia',$sousuoyeguanggaoweixia);
		//微博热搜榜
		$weiboresoubang=M('sousuojilu')->where("sousuoci!='搜名字/广播'")->order('cishu desc,id desc')->limit('0,10')->select();
		$this->assign('weiboresoubang',$weiboresoubang);
		//搜索历史		
		$sousuolishi=M('sousuojilu')->where("zhu_id=".$_SESSION['user_id']." and sousuoci!='搜名字/广播'")->order('id desc')->limit('0,10')->select();
		$this->assign('sousuolishi',$sousuolishi);

		  $this->display(ss); 
	}
	//搜索话题
	function sousuohuati(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$sousuosousuoci=$_POST['sousuoci'];
		$_POST['zhu_id']=$_SESSION['user_id'];
		$_POST['cishu']="0";
		if($_POST['sousuoci']=='' || $_POST['sousuoci']==' ' || $_POST['sousuoci']=='  ' || $_POST['sousuoci']=='   ' || $_POST['sousuoci']=='    ' || $_POST['sousuoci']=='     ' || $_POST['sousuoci']=='      ' || $_POST['sousuoci']=='       ' || $_POST['sousuoci']=='        ' || $_POST['sousuoci']=='         ' || $_POST['sousuoci']=='          ' || $_POST['sousuoci']=='           ' || $_POST['sousuoci']=='            ' || $_POST['sousuoci']=='	' || $_POST['sousuoci']=='搜名字/广播'){
			$this->error("请输入搜索内容");	
		}
		if( M('sousuojilu')->add($_POST) ){
			
			$sousuoyuan=M('sousuojilu')->where("sousuoci='$sousuosousuoci'")->order('id asc')->limit('1')->find();  
			$sousuoxian['id']=$sousuoyuan['id'];
			$sousuoxian['cishu']=$sousuoyuan['cishu']+"1";
			M('sousuojilu')->save($sousuoxian);
		}
		//搜索话题
		$where="#".$sousuosousuoci."#";
		 import("@.ORG.Page");
		 	$count3	= M('weibo')->where("content like '%$where%'")->count();
			$Page3	= New Page($count3,12);
			$show3	= $Page3->show();
		$sousuoweibo=M('weibo')->where("content like '%$where%'")->order('time desc')->limit($Page3->firstRow.','.$Page3->listRows)->select();
			foreach($sousuoweibo as $k=>$v){
					$sousuoweibo[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
						foreach($sousuoweibo[$k]['pinglun'] as $kk=>$vv){
							$fasongzhe=M('user')->find($vv['fasongzhe']);
							$sousuoweibo[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
							$sousuoweibo[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
							$sousuoweibo[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
							foreach($sousuoweibo[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
								$nicheng=M('user')->find($vvv['fasongzhe']);
								$sousuoweibo[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
								$sousuoweibo[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
							}
						}

				 
				 $zuozhe=M('user')->find($v['zuozhe']);
				 $sousuoweibo[$k]['user_name']=$zuozhe['nicheng'];
				 $sousuoweibo[$k]['user_touxiang']=$zuozhe['touxiang'];
				 $sousuoweibo[$k]['user_id']=$zuozhe['id'];
				 //时间格式转换开始			 
				 if(date("YmdHi",$sousuoweibo[$k]['time'])==date("YmdHi",time())){
				 	 $sousuoweibo[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$sousuoweibo[$k]['time'])."秒前";	 
				 }else{
					 if(date("YmdH",$sousuoweibo[$k]['time'])==date("YmdH",time())){
						 $sousuoweibo[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$sousuoweibo[$k]['time'])."分钟前"; 
					 }else{
					  	 if(date("Ymd",$sousuoweibo[$k]['time'])==date("Ymd",time())){
							 $sousuoweibo[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$sousuoweibo[$k]['time'])."小时前"; 
						 }else{
							 if(date("Y",$sousuoweibo[$k]['time'])==date("Y",time())){
						 		 $sousuoweibo[$k]['fabushijian']=date("m月d日 H:i",$sousuoweibo[$k]['time']);
							 }else{
								 $sousuoweibo[$k]['fabushijian']=date("Y年m月d日 H:i",$sousuoweibo[$k]['time']);
							 }
						 } 
					 }
				 }
				 //时间格式转换结束
				 if($sousuoweibo[$k]['jiajing']=="1"){
					 $sousuoweibo[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
				 }else{
					 $sousuoweibo[$k]['jingpinbiaozhi']="";
				 }
				 $pindao=M('pindao')->find($v['pindao']);
				 $sousuoweibo[$k]['pindao_tupian']=$pindao['tupian'];
					 if($sousuoweibo[$k]['jiajing']=="1"){
						 $sousuoweibo[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
					 }else{
						 $sousuoweibo[$k]['jingpinbiaozhi']="";
					 }
					 if($sousuoweibo[$k]['tuijian']=="1"){
						 $sousuoweibo[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
					 }else{
						 $sousuoweibo[$k]['tuijianbiaozhi']="";
					 }
			 }			
		$this->assign('sousuoweibo',$sousuoweibo);
		$this->assign('page3',$show3);
		//广告位
		$sousuoyeguanggaoweishang=M('guanggaowei')->find('32');
		$this->assign('sousuoyeguanggaoweishang',$sousuoyeguanggaoweishang);
		$sousuoyeguanggaoweixia=M('guanggaowei')->find('33');
		$this->assign('sousuoyeguanggaoweixia',$sousuoyeguanggaoweixia);
		//微博热搜榜
		$weiboresoubang=M('sousuojilu')->where("sousuoci!='搜名字/广播'")->order('cishu desc,id desc')->limit('0,10')->select();
		$this->assign('weiboresoubang',$weiboresoubang);
		//搜索历史		
		$sousuolishi=M('sousuojilu')->where("zhu_id=".$_SESSION['user_id']." and sousuoci!='搜名字/广播'")->order('id desc')->limit('0,10')->select();
		$this->assign('sousuolishi',$sousuolishi);

		  $this->display(ss); 
	}
	 
	 
	//search
	function search(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$sousuosousuoci=$_POST['sousuoci'];
		$_POST['zhu_id']=$_SESSION['user_id'];
		$_POST['cishu']="0";
		if($_POST['sousuoci']=='' || $_POST['sousuoci']==' ' || $_POST['sousuoci']=='  ' || $_POST['sousuoci']=='   ' || $_POST['sousuoci']=='    ' || $_POST['sousuoci']=='     ' || $_POST['sousuoci']=='      ' || $_POST['sousuoci']=='       ' || $_POST['sousuoci']=='        ' || $_POST['sousuoci']=='         ' || $_POST['sousuoci']=='          ' || $_POST['sousuoci']=='           ' || $_POST['sousuoci']=='            ' || $_POST['sousuoci']=='	' || $_POST['sousuoci']=='搜名字/广播'){
			$this->error("请输入搜索内容");	
		}
		if( M('sousuojilu')->add($_POST) ){
			
			$sousuoyuan=M('sousuojilu')->where("sousuoci='$sousuosousuoci'")->order('id asc')->limit('1')->find();  
			$sousuoxian['id']=$sousuoyuan['id'];
			$sousuoxian['cishu']=$sousuoyuan['cishu']+"1";
			M('sousuojilu')->save($sousuoxian);
		}
		//搜索用户名
		 import("@.ORG.Page");
		 	$count2	= M('user')->where("nicheng like '%$sousuosousuoci%'")->count();
			$Page2	= New Page($count2,12);
			$show2	= $Page2->show();
		$sousuoyonghu=M('user')->where("nicheng like '%$sousuosousuoci%'")->order('id asc')->limit($Page2->firstRow.','.$Page2->listRows)->select();
		foreach($sousuoyonghu as $k=>$v){
			$sheng_name=M('city')->find($v['sheng']);
			$sousuoyonghu[$k]['sheng_name']=$sheng_name['city_name'];
			$shi_name=M('city')->find($v['shi']);
			$sousuoyonghu[$k]['shi_name']=$shi_name['city_name'];
			if($v['xingbie']=="1"){
				$sousuoyonghu[$k]['xingbie']="男";
			}
			if($v['xingbie']=="2"){
				$sousuoyonghu[$k]['xingbie']="女";
			}
		}
		$this->assign('sousuoyonghu',$sousuoyonghu);
		$this->assign('page2',$show2);
		//搜索微博
		 import("@.ORG.Page");
		 	$count3	= M('weibo')->where("content like '%$sousuosousuoci%'")->count();
			$Page3	= New Page($count3,12);
			$show3	= $Page3->show();
		$sousuoweibo=M('weibo')->where("content like '%$sousuosousuoci%'")->order('time desc')->limit($Page3->firstRow.','.$Page3->listRows)->select();
			foreach($sousuoweibo as $k=>$v){
					$sousuoweibo[$k]['pinglun'] = M('pinglun')->where("weibo_id=".$v['id']." and pinglun_id=0")->order('time desc')->select();
						foreach($sousuoweibo[$k]['pinglun'] as $kk=>$vv){
							$fasongzhe=M('user')->find($vv['fasongzhe']);
							$sousuoweibo[$k]['pinglun'][$kk]['fasongname']=$fasongzhe['nicheng'];
							$sousuoweibo[$k]['pinglun'][$kk]['fasongtouxiang']=$fasongzhe['touxiang'];
							$sousuoweibo[$k]['pinglun'][$kk]['pinglunhuifu']=M('pinglun')->where("pinglun_id='".$vv['id']."'")->order('time asc')->select();
							foreach($sousuoweibo[$k]['pinglun'][$kk]['pinglunhuifu'] as $kkk=>$vvv){
								$nicheng=M('user')->find($vvv['fasongzhe']);
								$sousuoweibo[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongname']=$nicheng['nicheng'];
								$sousuoweibo[$k]['pinglun'][$kk]['pinglunhuifu'][$kkk]['fasongtouxiang']=$nicheng['touxiang'];		
							}
						}

				 
				 $zuozhe=M('user')->find($v['zuozhe']);
				 $sousuoweibo[$k]['user_name']=$zuozhe['nicheng'];
				 $sousuoweibo[$k]['user_touxiang']=$zuozhe['touxiang'];
				 $sousuoweibo[$k]['user_id']=$zuozhe['id'];
				 //时间格式转换开始			 
				 if(date("YmdHi",$sousuoweibo[$k]['time'])==date("YmdHi",time())){
				 	 $sousuoweibo[$k]['fabushijian']=date("YmdHis",time())-date("YmdHis",$sousuoweibo[$k]['time'])."秒前";	 
				 }else{
					 if(date("YmdH",$sousuoweibo[$k]['time'])==date("YmdH",time())){
						 $sousuoweibo[$k]['fabushijian']=date("YmdHi",time())-date("YmdHi",$sousuoweibo[$k]['time'])."分钟前"; 
					 }else{
					  	 if(date("Ymd",$sousuoweibo[$k]['time'])==date("Ymd",time())){
							 $sousuoweibo[$k]['fabushijian']=date("YmdH",time())-date("YmdH",$sousuoweibo[$k]['time'])."小时前"; 
						 }else{
							 if(date("Y",$sousuoweibo[$k]['time'])==date("Y",time())){
						 		 $sousuoweibo[$k]['fabushijian']=date("m月d日 H:i",$sousuoweibo[$k]['time']);
							 }else{
								 $sousuoweibo[$k]['fabushijian']=date("Y年m月d日 H:i",$sousuoweibo[$k]['time']);
							 }
						 } 
					 }
				 }
				 //时间格式转换结束
					 if($sousuoweibo[$k]['jiajing']=="1"){
						 $sousuoweibo[$k]['jingpinbiaozhi']="<img src=\"__PUBLIC__/img/jp.png\" style=\"position:absolute;z-index:11;\" />";
					 }else{
						 $sousuoweibo[$k]['jingpinbiaozhi']="";
					 }
					 if($sousuoweibo[$k]['tuijian']=="1"){
						 $sousuoweibo[$k]['tuijianbiaozhi']="<img src=\"__PUBLIC__/img/jtb.png\" style=\"position:absolute;z-index:11;margin:75px 0 0 -30px;\" />";
					 }else{
						 $sousuoweibo[$k]['tuijianbiaozhi']="";
					 }
				 $pindao=M('pindao')->find($v['pindao']);
				 $sousuoweibo[$k]['pindao_tupian']=$pindao['tupian'];

			 }			
		$this->assign('sousuoweibo',$sousuoweibo);
		$this->assign('page3',$show3);
		//广告位
		$sousuoyeguanggaoweishang=M('guanggaowei')->find('32');
		$this->assign('sousuoyeguanggaoweishang',$sousuoyeguanggaoweishang);
		$sousuoyeguanggaoweixia=M('guanggaowei')->find('33');
		$this->assign('sousuoyeguanggaoweixia',$sousuoyeguanggaoweixia);
		//微博热搜榜
		$weiboresoubang=M('sousuojilu')->where("sousuoci!='搜名字/广播'")->order('cishu desc,id desc')->limit('0,10')->select();
		$this->assign('weiboresoubang',$weiboresoubang);
		//搜索历史		
		$sousuolishi=M('sousuojilu')->where("zhu_id=".$_SESSION['user_id']." and sousuoci!='搜名字/广播'")->order('id desc')->limit('0,10')->select();
		$this->assign('sousuolishi',$sousuolishi);

		  $this->display(ss); 
	}
	//ss页转发微博
	function dozhuanfaweibosousuoweibo(){
	    header("Content-Type:text/html; charset=utf-8");

		$zhuanfa['at_user']=$_POST['at_user'];
		$zhuanfa['time']=time();
		$zhuanfa['zhuanfazhe']=$_SESSION['user_id'];
		$weiboid=$_POST['weibo_id'];
		$yuanweibo=M('weibo')->find($weiboid);
		$zhuanfa['zuozhe']=$_SESSION['user_id'];
		$zhuanfa['content']=$yuanweibo['content'];		
		$zhuanfa['yuedushu']="0";
		$zhuanfa['zanshu']="0";
		$zhuanfa['caishu']="0";
		$zhuanfa['pindao']=$yuanweibo['pindao'];
		$zhuanfa['tuijian']="0";
		$zhuanfa['jiajing']="0";
		$zhuanfa['wenzilian']="0";
		$zhuanfa['ttime']="0";
		$zhuanfa['jtime']="0";
		$zhuanfa['wtime']="0";
		$zhuanfa['wenzi']="";
		$zhuanfa['zhiding']="0";
		$zhuanfa['zhitime']="0";
		$zhuanfa['suoshuweibo_id']=$yuanweibo['id'];
		$zhuanfa['suoshuzuozhe_id']=$yuanweibo['zuozhe'];
			
		if($zhuanfa['zhuanfazhe']=='0' || $zhuanfa['zuozhe']=='0' || $zhuanfa['suoshuweibo_id']=='0' ){
			$this->error("信息不完整");	
		}
		if($_SESSION['user_id']!=""){
			  if( M('weibo')->add($zhuanfa) ){
					$useryuan=M('user')->find($_SESSION['user_id']);  
					if($useryuan['zhuanfacishu']>=1){
						$user['id']=$_SESSION['user_id'];
						$user['zhuanfacishu']=$useryuan['zhuanfacishu']-1;
						$user['jifen']=$useryuan['jifen']+1;
						M('user')->save($user);
					}	
					$this->success('转发成功！');
			  }else{
					$this->error('转发失败！');
			  }
		}else{
			$this->error("请登录");	
		}
		
	}
	 
	//ss页发评论
	function dopinglunsss(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['time']=time();
		$_POST['fasongzhe']=$_SESSION['user_id'];
		$fasong=$_POST['weibo_id'];
		$fasongid=M('weibo')->find($fasong);
		$_POST['jieshouzhe']=$fasongid['zuozhe'];
		$_POST['pinglun_id']="0";
		if($_POST['content']==''){
			$this->error("信息不完整");	
		}
		if($_SESSION['user_id']==""){
			$this->error("请登录");	
		}else{
		      if( M('pinglun')->add($_POST) ){
					$useryuan=M('user')->find($_SESSION['user_id']);  
					if($useryuan['pingluncishu']>=1){
						$user['id']=$_SESSION['user_id'];
						$user['pingluncishu']=$useryuan['pingluncishu']-1;
						$user['jifen']=$useryuan['jifen']+1;
						M('user')->save($user);
					}	
				  
					$this->success('评论成功！');
			  }else{
					$this->error('评论失败！');
			  }
		}
	}	
	//ss页发评论回复
	function dogrwbsypinglunhuifusss(){
	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['time']=time();
		$_POST['fasongzhe']=$_SESSION['user_id'];
		$fasong=$_POST['pinglun_id'];
		$fasongid=M('pinglun')->find($fasong);
		$_POST['jieshouzhe']=$fasongid['fasongzhe'];
		$_POST['weibo_id']=$fasongid['weibo_id'];
		if($_POST['content']==''){
			$this->error("信息不完整");	
		}
		if($_SESSION['user_id']==""){
			$this->error("请登录");	
		}else{
		      if( M('pinglun')->add($_POST) ){
					$useryuan=M('user')->find($_SESSION['user_id']);  
					if($useryuan['pingluncishu']>=1){
						$user['id']=$_SESSION['user_id'];
						$user['pingluncishu']=$useryuan['pingluncishu']-1;
						$user['jifen']=$useryuan['jifen']+1;
						M('user')->save($user);
					}	

					$this->success('评论成功！');
			  }else{
					$this->error('评论失败！');
			  }
		}
	}



	
	
	
} 